Submission #1117215

#TimeUsernameProblemLanguageResultExecution timeMemory
1117215Marco_EscandonRemittance (JOI19_remittance)C++11
0 / 100
1 ms504 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define x first #define y second ll dx[]={1, 1, 0,-1,-1, -1, 0, 1}; ll dy[]={0, 1, 1, 1, 0, -1,-1,-1}; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); ll n; cin>>n; vector<ll> a(n),b(n); for(int i=0; i<n; i++) { cin>>a[i]>>b[i]; } ll pl=true; while(pl) { pl=false; for(int i=0; i<n; i++) { if(a[i]>b[i]&&(b[i]>1||(a[i]-b[i])%2==0)) { ll t1=(a[i]-b[i]+1)/2; a[i]-=t1*2; a[(i+1)%n]+=t1; pl=true; } if(a[i]>b[i]) { ll t1=(a[i]-b[i])/2; a[i]-=t1*2; a[(i+1)%n]+=t1; if(t1!=0) pl=true; } } } if(a!=b) { cout<<"No"; } else cout<<"Yes"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...