# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163909 | ho94949 | Remittance (JOI19_remittance) | C++17 | 407 ms | 28048 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;
const int MAXN = 1010101;
long long X[MAXN]; // should spend total Xi Yen
int main()
{
int N; scanf("%d", &N);
bool alleq = true, allb0 = true;
for(int i=0; i<N; ++i)
{
int a, b; scanf("%d%d", &a, &b);
X[i] = a-b;
if(a!=b) alleq = false;
if(b!=0) allb0 = false;
}
if(alleq)
{
puts("Yes");
return 0;
}
if(allb0)
{
puts("No");
return 0;
}
bool flag = true;
while(flag)
{
flag = false;
for(int i=0; i<N; ++i)
{
if(X[i] > 0)
{
flag = true;
int ni = i+1; if(ni==N) ni = 0;
X[ni] += (X[i]+1)/2;
if(X[i]%2==0) X[i] = 0;
else X[i] = -1;
}
}
}
for(int i=0; i<N; ++i)
if(X[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... |