Advertisement
Josif_tepe

Untitled

Mar 7th, 2022
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 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.     ios_base::sync_with_stdio(false);
  12.     int n;
  13.     cin >> n;
  14.     long long L = 0, R = 0;
  15.     for(int i = 1; i <= n; i++) {
  16.         int x; cin >> x;
  17.         int runda = n;
  18.         while(runda > 1) {
  19.             if(i <= (runda / 2)) {
  20.                 L += x;
  21.             }
  22.             else if(i > (runda / 2) and i <= runda){
  23.                 R += x;
  24.             }
  25.             runda /= 2;
  26.         }
  27.        
  28.     }
  29.     cout << L - R << endl;
  30.      return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement