제출 #547461

#제출 시각아이디문제언어결과실행 시간메모리
547461Monarchuwu커다란 상품 (IOI17_prize)C++17
0 / 100
74 ms288 KiB
#include "prize.h" using namespace std; int _n, ans; bool lollipop(int k) { return k * 2 >= _n; } bool dnc(int l, int r, int cntl, int cntr) { if (l > r) return false; int m = (l + r) >> 1; int p = m; vector<int> a; while (p <= r) { a = ask(p); if (a[0] + a[1] == 0) { ans = p; return true; } if (lollipop(a[0] + a[1])) break; ++p; } if (p <= r) { // [l, m-1] and [p+1, r] if (a[0] - (p - m) > cntl && dnc(l, m - 1, cntl, a[1] + (p - m))) return true; if (a[1] > cntr && dnc(p + 1, r, a[0], cntr)) return true; } else { if (dnc(l, m - 1, cntl, cntr + (p - m))) return true; } return false; } int find_best(int N) { _n = N; dnc(0, _n - 1, 0, 0); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...