#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n; vector<int64_t> a(n), b(n);
for(int i=0; i < n; i++) cin >> a[i] >> b[i];
//for(auto&A:a) cin >> A; for(auto&B:b) cin >> B;
int g = 1;
while(g){
g=0;
for(int i=0; i < n; i++){
//cerr << a[i] << "\n";
if(a[i] > b[i]){
a[(i+1)%n] += (a[i] - b[i] + 1)/2;
a[i] -= (a[i]-b[i]+1)/2*2;
g=1;
}
}
}
g=1;
//cerr << "DONE\n";
for(int i=0; i < n; i++){
cerr << a[i] << "\n";
g &= a[i] == b[i];
}
cout << (g?"YES":"NO") << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |