Advertisement
Josif_tepe

Untitled

Mar 7th, 2022
990
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. int main() {
  10.     ios_base::sync_with_stdio(false);
  11.     int n;
  12.     cin >> n;
  13.     long long L = 0, R = 0;
  14.     for(int i = 1; i <= n; i++) {
  15.         int x;
  16.         cin >> x;
  17.         int rundi = n;
  18.         while(rundi > 1) {
  19.             if(i <= rundi / 2) {
  20.                 L += x;
  21.             }
  22.             else if(i > rundi / 2 and i <= rundi) {
  23.                 R += x;
  24.             }
  25.             rundi /= 2;
  26.         }
  27.     }
  28.     cout << L - R << endl;
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement