Submission #209747

#TimeUsernameProblemLanguageResultExecution timeMemory
209747mhy908Remittance (JOI19_remittance)C++14
100 / 100
411 ms36348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; int n; LL a[1000010], b[1000010]; bool ans=true, allz=true; int main(){ scanf("%d", &n); for(int i=0; i<n; i++){ scanf("%lld %lld", &a[i], &b[i]); if(b[i])allz=false; if(a[i]!=b[i])ans=false; } /*if(allz){ if(ans)puts("Yes"); else puts("No"); return 0; }*/ while(1){ bool flag=false; for(int i=0; i<n; i++){ if(a[i]<=b[i])continue; LL temp=(a[i]-b[i]+1)/2; if(a[i]-temp*2<0)continue; a[i]-=temp*2; a[(i+1)%n]+=temp; flag=true; } for(int i=0; i<n; i++)assert(a[i]>=0); if(!flag)break; } for(int i=0; i<n; i++){ if(a[i]!=b[i]){ puts("No"); return 0; } } puts("Yes"); }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
remittance.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &a[i], &b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...