Submission #1076211

#TimeUsernameProblemLanguageResultExecution timeMemory
1076211aminThe Big Prize (IOI17_prize)C++14
90 / 100
46 ms2132 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector<int>q; int a[1000000],b[1000000]; int find_best(int n) { int cur=0; for(int i=0;i<n;i++) { a[i]=-1; b[i]=-1; } q=ask(0); a[0]=q[0]; b[0]=q[1]; int ma=max(ma,a[0]+b[0]); while(cur!=n) { // cout<<cur<<endl; if(a[cur]==-1) { q=ask(cur); a[cur]=q[0]; b[cur]=q[1]; } int p=a[cur]; int pp=b[cur]; if(p==0&&pp==0) return cur; if(p+pp<ma) { cur++; continue; } ma=max(ma,p+pp); int l=0; int j=sqrt(n); int r=min(n-cur,j); while(l<r-1) { int mid=(l+r)/2; if(a[cur+mid]==-1) { q=ask(cur+mid); a[cur+mid]=q[0]; b[cur+mid]=q[1]; } if(p==a[cur+mid]&&pp==b[cur+mid]) { l=mid; }else r=mid; } cur=r+cur; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:31:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |  if(p==0&&pp==0)
      |  ^~
prize.cpp:33:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |     if(p+pp<ma)
      |     ^~
prize.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^
prize.cpp:17:5: warning: 'ma' is used uninitialized in this function [-Wuninitialized]
   17 | int ma=max(ma,a[0]+b[0]);
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...