#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=1e6+5;
int N;
ll A[MX], B[MX];
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin>>N;
for(int i=0;i<N;i++) cin>>A[i]>>B[i];
for(int k=0;k<100000000;k++) {
for(int i=0;i<N;i++) {
if(A[i]>B[i]) {
ll nxt=(A[i]-B[i])/2;
A[i]-=2*nxt;
A[(i+1)%N]+=nxt;
}
}
}
bool ok=1;
for(int i=0;i<N;i++)
ok&=A[i]==B[i];
cout<<(ok?"Yes":"No")<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
884 ms |
2496 KB |
Output is correct |
2 |
Correct |
145 ms |
2492 KB |
Output is correct |
3 |
Correct |
149 ms |
2396 KB |
Output is correct |
4 |
Correct |
217 ms |
2488 KB |
Output is correct |
5 |
Correct |
381 ms |
2492 KB |
Output is correct |
6 |
Correct |
508 ms |
2488 KB |
Output is correct |
7 |
Correct |
509 ms |
2488 KB |
Output is correct |
8 |
Incorrect |
875 ms |
2396 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
884 ms |
2496 KB |
Output is correct |
2 |
Correct |
145 ms |
2492 KB |
Output is correct |
3 |
Correct |
149 ms |
2396 KB |
Output is correct |
4 |
Correct |
217 ms |
2488 KB |
Output is correct |
5 |
Correct |
381 ms |
2492 KB |
Output is correct |
6 |
Correct |
508 ms |
2488 KB |
Output is correct |
7 |
Correct |
509 ms |
2488 KB |
Output is correct |
8 |
Incorrect |
875 ms |
2396 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
884 ms |
2496 KB |
Output is correct |
2 |
Correct |
145 ms |
2492 KB |
Output is correct |
3 |
Correct |
149 ms |
2396 KB |
Output is correct |
4 |
Correct |
217 ms |
2488 KB |
Output is correct |
5 |
Correct |
381 ms |
2492 KB |
Output is correct |
6 |
Correct |
508 ms |
2488 KB |
Output is correct |
7 |
Correct |
509 ms |
2488 KB |
Output is correct |
8 |
Incorrect |
875 ms |
2396 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |