# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152318 | ivandasfs | Remittance (JOI19_remittance) | C++14 | 978 ms | 28676 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 <iostream>
#include <cstdio>
using namespace std;
pair<int, int> p[1000005];
int main() {
int n;
scanf("%d", &n);
for (int i=0 ; i<n ; i++) {
scanf("%d %d", &p[i].first, &p[i].second);
}
int off=0;
for (int j=0 ; j<50*n ; j++) {
if (j==25) off++;
int i = j%n;
int k = (i+1)%n;
if (p[i].first>p[i].second) {
int br = (p[i].first - p[i].second + off) / 2;
if (p[i].first < br*2) continue;
p[i].first -= br*2;
p[k].first += br;
}
}
for (int i=0 ; i<n ; i++) {
if (p[i].first != p[i].second) {
printf("No\n");
return 0;
}
}
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... |