# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254718 | dolphingarlic | Remittance (JOI19_remittance) | C++14 | 413 ms | 16204 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>
typedef long long ll;
using namespace std;
ll a[1000000], b[1000000];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%lld %lld", a + i, b + i);
if (!accumulate(b, b + n, 0))
return cout << (accumulate(a, a + n, 0) ? "No" : "Yes"), 0;
bool p = true;
for (int i = 0; i < 50; i++) {
for (int i = 0; i < n; i++) {
if (a[i] > b[i]) {
a[(i + 1) % n] += (a[i] - b[i] + 1) / 2;
a[i] -= (a[i] - b[i] + 1) / 2 * 2;
}
}
}
p = true;
for (int i = 0; i < n; i++) p &= (a[i] == b[i]);
puts(p ? "Yes" : "No");
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... |