제출 #132760

#제출 시각아이디문제언어결과실행 시간메모리
132760Talant커다란 상품 (IOI17_prize)C++17
90 / 100
130 ms24104 KiB
#include "prize.h" #include <bits/stdc++.h> #define sc second #define fr first #define mk make_pair #define pb push_back using namespace std; const int N = (1e6 + 5); const int inf = (1e9 + 7); vector <int> res[N]; int mx,cur; int find_best(int n) { for (int i = 0; i < min(n,474); i ++) { if (res[i].size() == 0) res[i] = ask(i); int s = res[i][0] + res[i][1]; if (!s) return i; if (s >= mx) mx = s,cur = i; } while(1) { if (res[cur].size() == 0) res[cur] = ask(cur); if (res[cur][0] + res[cur][1] == 0) return cur; if (res[cur][0] + res[cur][1] != mx) { cur ++; continue; } int lf = res[cur][0]; int rt = res[cur][1]; int l = cur,r = min(cur + 512,n - 1); if (res[r].size() == 0) res[r] = ask(r); if (res[r][0] + res[r][1] == 0) return r; if (res[l] == res[r]) { cur = r; continue; } while (r - l > 1) { int m = (r + l) >> 1; if (res[m].size() == 0) res[m] = ask(m); if (res[m][0] + res[m][1] == 0) return m; if (res[m][0] == lf && res[m][1] == rt) l = m; else r = m; } if (res[r].size() == 0) res[r] = ask(r); if (res[r][0] + res[r][1] == 0) return r; if (res[r][0] == lf && res[r][1] == rt) l = r; if (cur == l) l ++; cur = l; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...