제출 #776961

#제출 시각아이디문제언어결과실행 시간메모리
776961faruk커다란 상품 (IOI17_prize)C++17
20 / 100
80 ms336 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int sqrtn = 450; int find_best(int n) { sqrtn = min(sqrtn, n); int max_sum = 0; for (int i = 0; i < sqrtn; i++) { auto a = ask(i); max_sum = max(max_sum, a[0] + a[1]); if (a[0] + a[1] == 0) { return i; } } for (int i = sqrtn; i < n; i++) { auto val = ask(i); if (val[0] + val[1] != max_sum) { if (val[0] + val[1] == 0) return i; continue; } int rval = val[1]; int l = i, r = n - 1, ans = -1; while (l < r) { int mid = (l + r) / 2; auto midval = ask(mid); if (midval[0] + midval[1] != max_sum || midval[1] < rval) r = mid; else l = mid + 1, ans = mid; } i = ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...