# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211635 | m3r8 | Remittance (JOI19_remittance) | C++14 | 380 ms | 36472 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 <stdio.h>
#define N 1000100
#define ll long long
ll A[N];
ll B[N];
int cnt[N];
int main(void){
int n;
int nn = 1;
int nnn = 1;
scanf("%d",&n);
for(int i = 0;i<n;i++){
scanf("%lld %lld",&A[i],&B[i]);
if(B[i] != 0)nn = 0;
if(A[i] != 0)nnn = 0;
};
int pos = 1;
if(nn && !nnn)pos = 0;
if(pos){
int end = 1;
while(end){
end = 0;
for(int i = 0;i<n;i++){
if(A[i] > B[i]){
ll diff = A[i] - B[i];
if(diff % 2)diff++;
if(A[i] >= diff){
end = 1;
A[i] -= diff;
A[(i+1)%n] += diff/2;
};
};
};
};
for(int i = 0;i<n;i++){
if(A[i] != B[i]){
pos = 0;
break;
};
};
};
if(pos)printf("Yes\n");
else printf("No\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... |