Submission #677963

#TimeUsernameProblemLanguageResultExecution timeMemory
677963arnold518Remittance (JOI19_remittance)C++17
100 / 100
256 ms23888 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e6; int N; ll A[MAXN+10], B[MAXN+10], X[MAXN+10], S; int main() { scanf("%d", &N); for(int i=1; i<=N; i++) scanf("%lld%lld", &A[i], &B[i]), S+=B[i]-A[i]; ll p=0, q=1; for(int i=1; i<=N; i++) { p+=q*(B[i]-A[i]); q*=2; } if(p%(q-1)!=0) return !printf("No\n"); ll x=p/(1-q); for(int i=N; i>=1; i--) { x=x*2+B[i]-A[i]; if(x<0) return !printf("No\n"); X[i]=x; } for(int i=1; i<=N; i++) if(X[i]==0) return !printf("Yes\n"); bool flag=false; for(int i=1; i<=N; i++) if(B[i]!=0) flag=true; if(!flag) return !printf("No\n"); return !printf("Yes\n"); }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
remittance.cpp:16:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  for(int i=1; i<=N; i++) scanf("%lld%lld", &A[i], &B[i]), S+=B[i]-A[i];
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...