# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522791 | CPSC | Remittance (JOI19_remittance) | C++14 | 804 ms | 28688 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# 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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |