Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <cstring>
- #include <fstream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- long long add = 0, subtract = 0;
- for(int i = 1; i <= n; i++) {
- int x;
- cin >> x;
- int rounds = n;
- while(rounds > 1) {
- if(i <= rounds / 2) {
- add += x;
- }
- else if(i > rounds / 2 and i <= rounds) {
- subtract += x;
- }
- rounds /= 2;
- }
- }
- cout << add - subtract << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement