SHARE
TWEET

Problem A

a guest Oct 16th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define PI_INT 3.14159265358979323846
  3. #define PI acos(-1.0)
  4. #define LL long long
  5. #define N 100000007
  6. #define MOD 10000007
  7. #define MX numeric_limits<long long>::max();
  8. #define MN numeric_limits<long long>::min();
  9. #define READ(f) freopen(f, "r", stdin)
  10. #define WRITE(f) freopen(f, "w", stdout)
  11. #define FILL(v, n) fill(v.begin(), v.end(), n);
  12. #define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
  13. #define PRINT(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
  14. #define SCAN(v) for(int i=0; i<n; i++) { int temp; cin>>temp; v.push_back(temp); }
  15. #define SORT(v) sort(v.begin(), v.end());
  16.  
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21.     int n;
  22.     cin >> n;
  23.  
  24.     vector<int>v;
  25.  
  26.     bool flag=true;
  27.  
  28.     for(int i=0; i<n; i++)
  29.     {
  30.         int temp;
  31.         cin >> temp;
  32.  
  33.         if(temp%2==0)
  34.         {
  35.             v.push_back(temp/2);
  36.         }
  37.  
  38.         else
  39.         {
  40.             if(flag==true)
  41.             {
  42.                 int temp2=temp+1;
  43.                 v.push_back(temp2/2);
  44.  
  45.                 flag=false;
  46.             }
  47.  
  48.             else
  49.             {
  50.                 int temp2=temp-1;
  51.                 v.push_back(temp2/2);
  52.  
  53.                 flag=true;
  54.             }
  55.         }
  56.     }
  57.  
  58.     for(int i=0; i<v.size(); i++)
  59.     {
  60.         cout<<v[i]<<endl;
  61.     }
  62.  
  63.     return 0;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top