Submission #1161952

#TimeUsernameProblemLanguageResultExecution timeMemory
1161952gelastropodThe Big Prize (IOI17_prize)C++20
90 / 100
24 ms1944 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int find_best(int n) { // 5 types! vector<pair<int, int>> cache(n, { -1, -1 }); int lolpop = 0; for (int i = 0; i < min(n, 500); i++) { auto j = ask(i); lolpop = max(lolpop, j[0] + j[1]); if (j[0] + j[1] == 0) return i; } int crnt = 0; while (crnt < n) { auto qry = cache[crnt]; if (qry.first == -1) { auto j = ask(crnt); qry = { j[0], j[1] }; } if (qry.first + qry.second == 0) return crnt; if (qry.first + qry.second == lolpop) break; crnt++; } while (crnt < n) { auto crntval = cache[crnt]; if (crntval.first == -1) { auto j = ask(crnt); crntval = { j[0], j[1] }; } int low = crnt, high = n - 1, ans = crnt; while (low <= high) { int x = (low + high) / 2; pair<int, int> qry = cache[x]; if (qry.first == -1) { auto j = ask(x); qry = { j[0], j[1] }; } if (qry.second != crntval.second) { high = x - 1; } else { low = x + 1; ans = x; } } crnt = ans + 1; while (crnt < n) { auto qry = cache[crnt]; if (qry.first == -1) { auto j = ask(crnt); qry = { j[0], j[1] }; } if (qry.first + qry.second == 0) return crnt; if (qry.first + qry.second == lolpop) break; crnt++; } } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...