# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209747 | mhy908 | Remittance (JOI19_remittance) | C++14 | 411 ms | 36348 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];
bool ans=true, allz=true;
int main(){
scanf("%d", &n);
for(int i=0; i<n; i++){
scanf("%lld %lld", &a[i], &b[i]);
if(b[i])allz=false;
if(a[i]!=b[i])ans=false;
}
/*if(allz){
if(ans)puts("Yes");
else puts("No");
return 0;
}*/
while(1){
bool flag=false;
for(int i=0; i<n; i++){
if(a[i]<=b[i])continue;
LL temp=(a[i]-b[i]+1)/2;
if(a[i]-temp*2<0)continue;
a[i]-=temp*2;
a[(i+1)%n]+=temp;
flag=true;
}
for(int i=0; i<n; i++)assert(a[i]>=0);
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... |