Submission #790802

#TimeUsernameProblemLanguageResultExecution timeMemory
790802petezaThe Big Prize (IOI17_prize)C++14
0 / 100
5 ms296 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; bool vis[200005]; int find_best(int n) { if(n == 1) return 0; int mx = -1, ci; int c0, c1; for(int i=0;i<min(n, 500);i++) { auto e = ask(i); if(e[0] + e[1] > mx) { c0 = e[0], c1=e[1]; mx = e[0] + e[1]; ci = i; } } //start at ci exit(0); int l, r, mid; while(1) { l = ci; r = n-1; while(l<=r) { mid = (l+r) >> 1; auto e = ask(mid); if(e[0] + e[1] != mx) r = mid-1; else if(e[0] == c0) l = mid+1; else r = mid - 1; } for(int i=ci;i<l;i++) vis[i] = 1; ci = l; auto e = ask(ci); while(ci < n && e[0] + e[1] != mx) { if(ci >= n-1) break; e = ask(++ci); c0 = e[0]; c1 = e[1]; } if(ci >= n-1) break; } for(int i=0;i<n;i++) { if(vis[i]) continue; auto e = ask(i); if(e[0] + e[1] == 0) return i; } return 0; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:10:13: warning: variable 'c1' set but not used [-Wunused-but-set-variable]
   10 |     int c0, c1;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...