# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
233322 | triple_fault | Remittance (JOI19_remittance) | C++14 | 382 ms | 36596 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.
/* May 20 2020 */
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <random>
#define ll long long
using namespace std;
int main(void) {
ll n; scanf("%lld", &n);
ll a[n], b[n];
for (ll i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &b[i]);
ll nonzero_a = 0, nonzero_b = 0;
for (ll i = 0; i < n; ++i) {
nonzero_a |= (a[i] > 0);
nonzero_b |= (b[i] > 0);
}
if (!nonzero_b) {
if (nonzero_a) puts("No");
else puts("Yes");
return 0;
}
for (;;) {
bool uhh = false;
for (ll i = 0; i < n; ++i) {
if (a[i] <= b[i]) continue;
uhh = true;
ll ts = (a[i] - b[i] + 1) / 2;
a[(i + 1) % n] += ts;
a[i] -= (2 * ts);
}
if (!uhh) break;
}
for (ll i = 0; i < n; ++i)
if (a[i] != b[i]) {
puts("No");
return 0;
}
puts("Yes");
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... |