Advertisement
tepyotin2

#1.2 Lucky Charms

Dec 9th, 2023
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     ios_base::sync_with_stdio(0), cin.tie(0);
  7.     int l = 0, c = 0, n = 0;
  8.     cin >> l >> c >> n;
  9.     int si = 0, pi = 0;
  10.     int ans = 0;
  11.     int val = 0;
  12.     for(int i=0; i<c; i++){
  13.         cin >> si >> pi;
  14.         if(pi<n){
  15.             val = n-pi;
  16.         }else{
  17.             val = pi-n;
  18.         }
  19.         // cout << val << '\n';
  20.         ans = val+si;
  21.         cout << ans << '\n';
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement