Submission #40214

#TimeUsernameProblemLanguageResultExecution timeMemory
40214jackyliuxxThe Big Prize (IOI17_prize)C++14
97.41 / 100
27 ms2020 KiB
#include "prize.h" #include <iostream> using namespace std; int gogo(int fr, int to, int lc, int rc, int mxc) { if (lc + rc == mxc) { return -1; } int mid = (fr + to) / 2; int lto = mid, rfr = mid + 1; vector<int> res; int n = to - fr; for (int i = 0; i < n; i++) { if (i & 1) { mid -= i; } else { mid += i; } lto = min(lto, mid); rfr = max(rfr, mid + 1); res = ask(mid); int c = res[0] + res[1]; if (c == 0) { return mid; } else if (c == mxc) { int lrc, rlc; if (mid == lto) { lrc = res[1]; rlc = res[0] + i; } else { lrc = res[1] + i; rlc = res[0]; } return max(gogo(fr, lto, lc, lrc, mxc), gogo(rfr, to, rlc, rc, mxc)); } } return -1; } int find_best(int n) { int mxc = 0; int lc = 0; for(int i = 0; i < n && i < 500; i++) { std::vector<int> res = ask(i); lc = res[0]; if(res[0] + res[1] == 0) return i; if (res[0] + res[1] > mxc) { mxc = res[0] + res[1]; } } return gogo(0, n, 0, 0, mxc); }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:43:9: warning: variable 'lc' set but not used [-Wunused-but-set-variable]
     int lc = 0;
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...