제출 #775755

#제출 시각아이디문제언어결과실행 시간메모리
775755APROHACK커다란 상품 (IOI17_prize)C++14
0 / 100
74 ms360 KiB
#include "prize.h" #include <bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second using namespace std; int sumMax = 0; bool confirm(vector<int>&t){ return t[0] + t[1] == 0; } int suma(vector<int>&t){return t[0] + t[1];} int find_best(int n) { vector<int>t; for(int i = 0 ; i < 500 ; i ++){ t = ask(i); sumMax = max(sumMax, t[0] + t[1]); if(t[0] + t[1] == 0)return i; } queue<pair<int, int> >cola; cola.push({500, n-1}); while(!cola.empty()){ pair<int, int> cur = cola.front(); cola.pop(); if(cur.ff > cur.ss)continue; if(cur.ff == cur.ss){ t = ask(cur.ff); if(confirm(t))return cur.ff; } int midd = (cur.ff + cur.ss)/2, toL, k; t = ask(midd); k = midd; toL = midd-1; bool thereIsR = true; while(suma(t) != sumMax){ if(confirm(t))return k; k++; if(k > cur.ss){ thereIsR = false; break; } t = ask(k); } if(thereIsR and k+1 <= cur.ss){ cola.push({k+1, cur.ss}); } if(toL >= cur.ff)cola.push({cur.ff, toL}); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...