Submission #718165

#TimeUsernameProblemLanguageResultExecution timeMemory
718165Jarif_RahmanThe Big Prize (IOI17_prize)C++17
100 / 100
55 ms5232 KiB
#include "prize.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; vector<int> asked[200000]; int ans = -1, mx = -1; vector<int> Ask(int i){ if(asked[i].empty()) asked[i] = ask(i); mx = max(mx, asked[i][0]+asked[i][1]); return asked[i]; } int Ask_cnt(int i){ auto v = Ask(i); if(v[0]+v[1] == 0) ans = i; return v[0]+v[1]; } void solve(int l, int r){ if(ans != -1) return; while(Ask_cnt(l) != mx && l <= r) l++; if(ans != -1) return; while(Ask_cnt(r) != mx && r >= l) r--; if(ans != -1) return; if(l >= r) return; auto a = Ask(l), b = Ask(r); if(a[0] == b[0] && a[1] == b[1]) return; int md = (l+r)/2; solve(l, md); solve(md, r); } int find_best(int n){ solve(0, n-1); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...