Submission #522791

#TimeUsernameProblemLanguageResultExecution timeMemory
522791CPSCRemittance (JOI19_remittance)C++14
100 / 100
804 ms28688 KiB
# include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; const int N = 1e6 + 5; int a[N],b[N],val,ff,n; main() { cin>>n; int ff = 0; int ff1 = 0; for (int i = 1; i <= n; i++) { cin>>a[i]>>b[i]; if (b[i] != 0) ff = 1; if (a[i] != 0) ff1 = 1; } if (!ff) { if (ff1) cout<<"No"<<endl; else cout<<"Yes"<<endl; return 0; } while (true) { ff = 0; for (int i = 1; i <= n; i++) { if (a[i] > b[i]) { val = (a[i] - b[i] + 1) / 2; val *= 2; if (i == n) { a[i] -= val; a[1] += val/2; } else a[i] -= val, a[i + 1] += val / 2; ff = 1; } } if (!ff) break; } for (int i = 1; i <= n; i++) { if (a[i] != b[i]) { cout<<"No"<<endl; exit(0); } } cout<<"Yes"<<endl; }

Compilation message (stderr)

remittance.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...