Submission #585370

#TimeUsernameProblemLanguageResultExecution timeMemory
585370VanillaThe Big Prize (IOI17_prize)C++17
90 / 100
106 ms11344 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; int nr[] = {1, 2, 5, 26, 677}; int vmx = 0, vpos = 0; const int maxn = 2e5 + 2; vector <vector <int> > mp (maxn, vector <int> {-1, -1}); vector <int> get (int x) { return mp[x] = ((mp[x] == vector <int> {-1, -1}) ? ask(x) : mp[x]); } int find_best(int n) { for (int i = 0; i < min(500, n); i++){ vector <int> k = ask(i); if (k[0] + k[1] > vmx) { vmx = k[0] + k[1]; vpos = i; } } int i = 0; while (i < n) { int l = i + 1, r = n - 1, rs = i; if (get(i)[0] + get(i)[1] == 0) return i; if (get(i)[0] + get(i)[1] < vmx) { i++; continue; } while (l <= r) { int mid = (l + r) / 2; if (get(mid)[0] + get(mid)[1] < vmx) { r = mid - 1; rs = mid; } else { if (get(mid)[0] - get(i)[0] != 0) { rs = mid; r = mid - 1; } else { l = mid + 1; } } } if (get(rs)[0] + get(rs)[1] == 0) return rs; i = rs + 1; } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...