# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209749 | mhy908 | Remittance (JOI19_remittance) | C++14 | 5 ms | 376 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>
using namespace std;
typedef long long LL;
int n;
LL a[1000010], b[1000010];
int main(){
scanf("%d", &n);
for(int i=0; i<n; i++)scanf("%lld %lld", &a[i], &b[i]);
while(1){
bool flag=false;
for(int i=0; i<n; i++){
if(a[i]<=b[i]||(a[i]==1&&b[i]==0))continue;
LL temp=(a[i]-b[i]+1)/2;
a[i]-=temp*2;
a[(i+1)%n]+=temp;
flag=true;
}
if(!flag)break;
}
for(int i=0; i<n; i++){
if(a[i]!=b[i]){
puts("No");
return 0;
}
}
puts("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... |