# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062372 | 2024-08-17T05:06:03 Z | Muhammad_Aneeq | The Big Prize (IOI17_prize) | C++17 | 0 ms | 0 KB |
#include <vector> using namespace std; int const N=2e5+10; bool vis[N]={}; vector<int>val[N]; vector<int> qu(int i) { if (vis[i]) return val[i]; vis[i]=1; val[i]=ask(i); return val[i]; } int sol(int st,int en) { int mid=(st+en)/2; vector<int>g=qu(mid); if (st==en) { if (g[0]||g[1]) return -1; return st; } int z=0; if (g[0]) z=sol(st,mid-1); else if (g[1]) z=max(z,sol(mid+1,en)); else z=mid; return z; } int find_best(int n) { return sol(0,n-1); }