Submission #581974

#TimeUsernameProblemLanguageResultExecution timeMemory
581974alirezasamimi100The Big Prize (IOI17_prize)C++17
20 / 100
91 ms300 KiB
#include "prize.h" #include <bits/stdc++.h> #define pb push_back using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int ans = -1, cnt = 0, mx = 0; vector<int> doask(int i){ vector<int> v = ask(i); if(v[0] == 0 && v[1] == 0) ans = i; return v; } void solve(int l, int r){ if(ans != -1) return; int g = 0; vector<int> u; while(r > l){ u = doask(r - 1); r--; if(u[0] + u[1] == mx) break; g++; } if(r == l) return; int m = (l + r) >> 1, t = 0, rm = m; vector<int> v; while(m < r){ v = doask(m); if(v[0] + v[1] == mx) break; t++; m++; } if(v[0] > cnt + t) solve(l, rm); cnt += t; if(m + 1 < r && v[1] - u[1] > 0) solve(m + 1, r); cnt += g; } int find_best(int n) { for(int i = 0; i < min(n, 700); i++){ vector<int> v = doask(i); if(v[0] + v[1] > mx) mx = v[0] + v[1]; } solve(0, n); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...