제출 #581957

#제출 시각아이디문제언어결과실행 시간메모리
581957alirezasamimi100커다란 상품 (IOI17_prize)C++17
20 / 100
51 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){ if(r - l == 1){ vector<int> v = doask(l); if(v[0] + v[1] < mx) cnt++; return; } int m = (l + r) >> 1, t = 0, rm = m; vector<int> v; while(m >= l){ v = doask(m); if(v[0] + v[1] == mx) break; t++; m--; } if(m > l && v[0] > cnt) solve(l, m); cnt += t; if(rm + 1 < r) solve(rm + 1, r); } int find_best(int n) { for(int i = 0; i < min(n, 1000); i++){ vector<int> v = ask(i); if(v[0] + v[1] > mx) mx = v[0] + v[1]; } solve(0, n); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...