# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1113622 | 2024-11-16T20:29:47 Z | epicci23 | 커다란 상품 (IOI17_prize) | C++17 | 0 ms | 0 KB |
#include "bits/stdc++.h" #include "prize.h" //#define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; const int BL = 10000; int suf = -1; vector<int> Cache = {-1, -1}; map<int,vector<int>> dp; vector<bool> mark; vector<int> Ask(int i){ if( dp.count(i) ) return dp[i]; return dp[i] = ask(i); } void Learn(int l,int r){ if(l > r) return -1; if(l == r){ mark[l] = 1; suf--; return; } int mid = (l + r) / 2; auto u = Ask(mid); if(u[1] == suf){ Learn(mid + 1, r); return; } Learn(l, mid - 1); if(u[1] < suf) suf--; Learn(mid + 1, r); return; } int find_best(int n){ mark.assign(n,0); int art = 0; bool no = 0; for(int i = 0; i <= 475; i++){ if(art == 5){ Learn(i, n - 1); no = 1; break; } vector<int> x = Ask(i); if(x[0] + x[1] == 0) return i; if(x[0] + x[1] > Cache[0] + Cache[1]) art++; if(x[0] + x[1] >= Cache[0] + Cache[1]){ Cache = x; suf = Cache[1]; } else suf--; } if(no == 0) Learn(476, n - 1); for(auto x:dp) if(x.second[0] + x.second[1] == 0) return x.first; for(int i=0;i<n;i++){ if(small[i]==0) continue; vector<int> Cand = Ask(i); if(Cand[0] + Cand[1] == 0) return i; } assert(0); return -1; }