Submission #321267

#TimeUsernameProblemLanguageResultExecution timeMemory
321267CaroLindaRemittance (JOI19_remittance)C++14
100 / 100
710 ms36484 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 ; 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)

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...