Submission #227249

#TimeUsernameProblemLanguageResultExecution timeMemory
227249alexandra_udristoiuRemittance (JOI19_remittance)C++14
100 / 100
383 ms28908 KiB
#include<iostream> #include<cstdio> #define DIM 1000005 using namespace std; int n, i, ok, x; int a[DIM], b[DIM]; long long sum, sum2; int nxt(int i){ if(i == n){ return 1; } return i + 1; } int main(){ scanf("%d", &n); ok = 1; for(i = 1; i <= n; i++){ scanf("%d%d", &a[i], &b[i]); if(a[i] != 0){ ok = 0; } sum2 += b[i]; } if(sum2 == 0 && ok == 0){ cout<<"No"; return 0; } do{ ok = 1; for(i = 1; i <= n; i++){ if(a[i] != b[i]){ ok = 0; if(a[i] > b[i]){ x = (a[i] - b[i]) / 2 + (a[i] - b[i]) % 2; a[ nxt(i) ] += x; a[i] -= 2 * x; } } } sum = 0; for(i = 1; i <= n; i++){ sum += a[i]; } if(sum < sum2){ break; } }while(ok == 0); if(ok == 1){ cout<<"Yes"; } else{ cout<<"No"; } }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
remittance.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a[i], &b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...