Submission #321272

#TimeUsernameProblemLanguageResultExecution timeMemory
321272CaroLinda송금 (JOI19_remittance)C++14
0 / 100
1 ms512 KiB
#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 ;
 
			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 ;
 
	bool everybodyOne = true ;

	for(int i = 0 ; i < n ; i++ ) 
		if(cash[i]-1 != desired[i] ) everybodyOne = false ;

	if(ok|everybodyOne) printf("Yes\n") ;
	else printf("No\n") ;
 
}

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d", &n ) ;
      |  ~~~~~^~~~~~~~~~~
remittance.cpp:14:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  for(int i= 0 ; i < n ; i++ ) scanf("%lld %lld", &cash[i] , &desired[i] ) ;
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...