Submission #54024

#TimeUsernameProblemLanguageResultExecution timeMemory
54024chpipisThe Big Prize (IOI17_prize)C++11
90 / 100
87 ms1428 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; int num_q; map<int, vi> memo; vi query(int x) { if (memo.count(x)) return memo[x]; num_q++; vi ret = ask(x); return memo[x] = ret; } int find_best(int n) { memo.clear(); num_q = 0; int mx = -1; for (int i = 0, j; i < n; i = j + 1) { if (i == n - 1) return i; j = i; vi cur = query(i); if (cur[0] + cur[1] == 0) return i; if (cur[0] + cur[1] < mx) continue; mx = max(mx, cur[0] + cur[1]); int lo = i + 1, hi = n - 1; while (lo <= hi) { int mid = (lo + hi) >> 1; vi now = query(mid); if (now[0] + now[1] == 0) return mid; if (now == cur) { lo = mid + 1; j = mid; } else { hi = mid - 1; } } } }

Compilation message (stderr)

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