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>
#define ll long long
#define f first
#define sc second
#define pb push_back
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l;
pair <ll,ll> A[1000006];
int main() {
cin>>n;
for(ll i=1;i<=n;i++) {
cin>>A[i].f>>A[i].sc;
}
while(true) {
b=0;
for(ll i=1;i<=n;i++) {
if(A[i].f<=A[i].sc) continue;
a=A[i].f-A[i].sc+1;
if(A[i].f<(a/2)*2) continue;
if(i==n) A[1].f+=a/2;
else A[i+1].f+=a/2;
if(a/2>0) b=1;
A[i].f-=(a/2)*2;
}
if(b==0) break;
}
a=0;
for(ll i=1;i<=n;i++) {
if(A[i].f!=A[i].sc) a=1;
}
if(a==1) cout<<"No";
else cout<<"Yes";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |