Advertisement
Josif_tepe

Untitled

Mar 9th, 2022
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <cstring>
  7. #include <fstream>
  8. using namespace std;
  9.  
  10. int main() {
  11.     int n;
  12.     cin >> n;
  13.     long long add = 0, subtract = 0;
  14.     for(int i = 1; i <= n; i++) {
  15.         int x;
  16.         cin >> x;
  17.         int rounds = n;
  18.         while(rounds > 1) {
  19.             if(i <= rounds / 2) {
  20.                 add += x;
  21.             }
  22.             else if(i > rounds / 2 and i <= rounds) {
  23.                 subtract += x;
  24.             }
  25.             rounds /= 2;
  26.         }
  27.     }
  28.     cout << add - subtract << endl;
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement