Submission #553937

#TimeUsernameProblemLanguageResultExecution timeMemory
553937timreizinThe Big Prize (IOI17_prize)C++17
20 / 100
3046 ms5012 KiB
#include "prize.h" #include <iostream> using namespace std; int find_best(int n) { vector<vector<int>> mem(n); int prev = 0; int sum = 0; for (int j = 0; j < min(300, n); ++j) { mem[j] = ask(j); vector<int> tmp = mem[j]; if (tmp[0] + tmp[1] == 0) return j; sum = max(sum, tmp[0] + tmp[1]); } for (int i = 1;; ++i) { int l = 0, r = n - 1; //first with not max level bool tryAgain = false; while (l < r) { int m = (l + r) >> 1; if (mem[m].empty()) mem[m] = ask(m); if (mem[m][0] + mem[m][1] == 0) return m; if ((sum == mem[m][0] + mem[m][1] && mem[m][0] != i) || m <= prev) l = m + 1; else r = m; } prev = l; if (mem[prev].empty()) mem[prev] = ask(prev); if (mem[prev][0] + mem[prev][1] == 0) return prev; ++prev; } } //1 2 5 26 677 - mins //1 4 21 446 200000 - maxs

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:22:14: warning: unused variable 'tryAgain' [-Wunused-variable]
   22 |         bool tryAgain = false;
      |              ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...