#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 = 10000; z--;){
for(int i = 0; i+1 < n; i++) {
if(a[i] > b[i]) {
a[i+1] += (a[i]-b[i]+1)/2;
a[i] -= 2*((a[i]-b[i]+1)/2);
}
}
if(a[n-1] > b[n-1]) {
a[0] += (a[n-1]-b[n-1]+1)/2;
a[n-1] -= 2*((a[n-1]-b[n-1]+1)/2);
}
}
int ok = 1;
for(int i = 0; i < n; i++) assert(a[i] >= b[i]);
for(int i = 0; i < n; i++) ok &= a[i] == b[i];
cout << (ok?"Yes":"No") << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |