제출 #581983

#제출 시각아이디문제언어결과실행 시간메모리
581983alirezasamimi100커다란 상품 (IOI17_prize)C++17
90 / 100
55 ms336 KiB
#include "prize.h" #include <bits/stdc++.h> #define pb push_back using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int ans = -1, cnt = 0, mx = 0; vector<int> doask(int i){ vector<int> v = ask(i); if(v[0] == 0 && v[1] == 0) ans = i; return v; } void solve(int l, int r, int x){ if(ans != -1) return; int m = (l + r) >> 1, t = 0, rm = m; vector<int> v; while(m < r){ v = doask(m); m++; if(v[0] + v[1] == mx) break; t++; } if(l < rm && v[0] > cnt + t) solve(l, rm, v[1] + t); cnt += t; if(m < r && v[1] - x > 0) solve(m, r, x); } int find_best(int n) { for(int i = 0; i < min(n, 500); i++){ vector<int> v = doask(i); if(v[0] + v[1] > mx) mx = v[0] + v[1]; } int x = 0; while(n){ vector<int> v = doask(n - 1); n--; if(v[0] + v[1] == mx) break; x++; } solve(0, n, x); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...