# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
279117 | ChrisT | Remittance (JOI19_remittance) | C++17 | 416 ms | 20856 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>
using namespace std;
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e6 + 5;
int n, a[MN], b[MN];
int main () {
scanf ("%d",&n);
long long sumA = 0, sumB = 0;
for (int i = 0; i < n; i++) {
scanf ("%d %d",&a[i],&b[i]);
sumA += a[i]; sumB += b[i];
}
bool change = 1;
while (change) {
change = 0;
for (int i = 0; i < n; i++) {
int diff = a[i] - b[i];
if (diff <= 0) continue;
int take = max(diff - (diff&1),2);
if (a[i] - take < 0) continue;
if ((sumA - take/2) < sumB) continue;
change = 1; sumA -= take/2;
a[i] -= take; a[(i+1)%n] += take/2;
}
}
for (int i = 0; i < n; i++) if (b[i] != a[i]) return !printf ("No\n");
printf ("Yes\n");
return 0;
}
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... |