# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
468075 | stefantaga | Remittance (JOI19_remittance) | C++14 | 301 ms | 36408 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 <cstdio>
#include <vector>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
vector<long long> A(n),B(n);
for(int i=0;i<n;i++){
scanf("%lld%lld",&A[i],&B[i]);
}
bool F,G=false;
for(int i=0;i<n;i++){
G|=(B[i]>0);
}
if(!G){
F=true;
for(int i=0;i<n;i++){
F&=(A[i]==0);
}
}
else{
bool loop=true;
while(loop){
loop=false;
for(int i=0;i<n;i++){
if(A[i]>B[i]){
long long t=(A[i]-B[i]+1)/2;
A[i]-=2*t;
A[(i+1)%n]+=t;
loop=true;
}
}
}
F=true;
for(int i=0;i<n;i++){
F&=(A[i]==B[i]);
}
}
puts(F?"Yes":"No");
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... |