This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MX=1e6+5;
int N;
int 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<1000;k++) {
for(int i=0;i<N;i++) {
if(A[i]>B[i]) {
int 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';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |