Submission #321625

#TimeUsernameProblemLanguageResultExecution timeMemory
321625LawlietRemittance (JOI19_remittance)C++17
0 / 100
1 ms492 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int lli; const int MAXN = 1000010; const lli INF = 1000000000000000000LL; int n; lli diff[MAXN]; void impossible() { printf("No\n"); exit(0); } void addCross(int i, lli qtd, lli& xCross, lli& xNext) { if( i >= 62 ) impossible(); lli p = (1LL << (i - 1)); if( qtd > INF/p ) impossible(); xNext += qtd; xCross += qtd*p; if( xCross >= INF ) impossible(); } int main() { scanf("%d",&n); for(int i = 1 ; i <= n ; i++) { int a, b; scanf("%d %d",&a,&b); diff[i] = a - b; } lli xCur = 0; lli xCross = 0; for(int i = 1 ; i < n ; i++) { lli xNext = diff[i] + xCur; if( xNext < 0 ) addCross( i , -xNext , xCross , xNext ); if( xNext%2 == 1 ) addCross( i , 1 , xCross , xNext ); xCur = xNext/2; } lli s = diff[n] + xCur; if( s%2 == 0 && s/2 == xCross ) printf("Yes\n"); else impossible(); }

Compilation message (stderr)

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