Submission #163909

#TimeUsernameProblemLanguageResultExecution timeMemory
163909ho94949Remittance (JOI19_remittance)C++17
100 / 100
407 ms28048 KiB
#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)

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