Submission #431731

# Submission time Handle Problem Language Result Execution time Memory
431731 2021-06-17T14:53:08 Z kostia244 Remittance (JOI19_remittance) C++17
Compilation error
0 ms 0 KB
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 16;
int n, a[N], b[N];
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for(int z = 30; z--;){
        for(int i = 0; i+1 < n; i++) {
            if(a[i] > b[i]) {
                a[i+1] += (a[i]-b[i]+(a[i]>0))/2;
                a[i] -= 2*((a[i]-b[i]+(a[i]>0))/2);
            }
        }
        if(a[n-1] > b[n-1]) {
            a[0] += (a[n-1]-b[n-1]+(a[i]>0))/2;
            a[n-1] -= 2*((a[n-1]-b[n-1]+(a[i]>0))/2);
        }
    //for(int i = 0; i < n; i++) cout << a[i] << " " << b[i] << endl;
    }
    int ok = 1;
    for(int i = 0; i < n; i++) ok &= a[i] == b[i];
    cout << (ok?"Yes":"No") << '\n';
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:20:39: error: 'i' was not declared in this scope
   20 |             a[0] += (a[n-1]-b[n-1]+(a[i]>0))/2;
      |                                       ^