제출 #137517

#제출 시각아이디문제언어결과실행 시간메모리
137517ckodser커다란 상품 (IOI17_prize)C++14
0 / 100
7 ms5112 KiB
#include "prize.h" #include<bits/stdc++.h> #define ll int #define pb push_back #define mp make_pair #define ld long double #define F first #define S second #define pii pair<ll,ll> using namespace :: std; const ll maxn=2e5+500; const ll inf=1e9+900; vector<ll> ansS[maxn]; ll mx=0; vector<ll> ASK(ll x){ if(ansS[x].size())return ansS[x]; ansS[x]=ask(x); mx=max(mx,ansS[x][0]+ansS[x][1]); return ansS[x]; } ll N; ll fmx; ll bild(ll l,ll r,ll L,ll R){ l=max(l,0); r=min(r,N); if(l>=r)return -1; if(L+R==mx)return -1; ll mid=(l+r)/2; for(ll i=mid;i<r;i++){ vector<ll> vec=ASK(i); if(mx!=fmx)return -2; if(vec[0]+vec[1]==mx){ ll XX=bild(l,mid,L,vec[1]+(mid-i)); if(XX==-2)return -2; if(XX!=-1)return XX; XX=bild(i+1,r,vec[0],R); if(XX==-2)return -2; if(XX!=-1)return XX; return -1; }else{ if(vec[0]+vec[1]==0)return i; } } return bild(l,mid,L,R+(r-mid)); } int find_best(int n) { N=n; if(n<=5000){ for(ll i=0;i<n;i++){ vector<ll> vec=ask(i); if(vec[0]+vec[1]==0)return i; } } ASK(0); while(1){ fmx=mx; ll x=bild(0,n,0,0); if(x!=-2)return x; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...