# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677658 | mjhmjh1104 | Remittance (JOI19_remittance) | C++17 | 230 ms | 15948 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 <cstdio>
int n;
long long a[1000006], b[1000006];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld%lld", a + i, b + i);
for (int i = 0; i < n; i++) a[i] -= b[i];
for (int i = 0; i < n; i++) {
long long curr = a[i];
int pos = i;
while (curr > 1) {
curr = curr / 2 * 2;
a[pos] -= curr;
pos = (pos + 1) % n;
curr /= 2;
a[pos] += curr;
curr = a[pos];
}
}
for (int i = 0; i < n; i++) {
long long curr = a[i];
if (b[i]) curr++;
int pos = i;
while (curr > 1) {
curr = curr / 2 * 2;
a[pos] -= curr;
pos = (pos + 1) % n;
curr /= 2;
a[pos] += curr;
curr = a[pos];
}
}
bool fl = false;
for (int i = 0; i < n; i++) if (a[i]) fl = true;
puts(fl ? "No" : "Yes");
}
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... |