Submission #402948

#TimeUsernameProblemLanguageResultExecution timeMemory
402948wildturtleRemittance (JOI19_remittance)C++14
100 / 100
931 ms36432 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...