# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321267 | CaroLinda | Remittance (JOI19_remittance) | C++14 | 710 ms | 36484 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>
const int MAX = 1e6+10 ;
using namespace std ;
int n ;
long long cash[MAX] , desired[MAX] ;
int main()
{
scanf("%d", &n ) ;
for(int i= 0 ; i < n ; i++ ) scanf("%lld %lld", &cash[i] , &desired[i] ) ;
for(int g = 0 ; g < 60 ; g++ )
{
for(int i= 0 , nxt = 1 ; i < n ; i++ , nxt++ )
{
if(nxt == n) nxt = 0 ;
long long leftOver = cash[i] - desired[i] ;
if(leftOver < 0 ) continue ;
leftOver++ ;
if(cash[i]-(leftOver/2LL)*2LL < 0LL ) continue ;
cash[i] -= (leftOver/2LL ) *2LL ;
cash[nxt] += leftOver/2LL ;
}
}
bool ok =true ;
for(int i= 0 ; i < n ; i++ )
if(cash[i] != desired[i] ) ok = false ;
if(ok) printf("Yes\n") ;
else printf("No\n") ;
}
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... |