Submission #952978

#TimeUsernameProblemLanguageResultExecution timeMemory
952978Alexabcde1Remittance (JOI19_remittance)C++14
100 / 100
252 ms36436 KiB
#include<bits/stdc++.h> #define f first #define s second using namespace std; long long n; long long a[1000005],b[1000005]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for (int i=0;i<n;i++) cin>>a[i]>>b[i]; long long cnt=50; while (cnt--){ for (int i=0;i<n;i++){ if (a[i]>b[i]){ long long give=(a[i]-max(0LL,b[i]-1))/2; if (give>0) a[i]-=give*2; if (give>0) a[(i+1)%n]+=give; } } } for (int i=0;i<n;i++){ if (a[i]!=b[i]) { cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...