제출 #58995

#제출 시각아이디문제언어결과실행 시간메모리
58995tugushka커다란 상품 (IOI17_prize)C++14
20 / 100
99 ms1764 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; vector < int > res, a; map < int, vector < int > > x; map < int , int > cnt; int sq, mx; int find_best(int n){ int now = 0; for( ; now < min(sq+30, n-1) ; now++ ){ res = ask(now); x[now] = res; cnt[res[0]+res[1]]++; mx = max( res[0]+res[1], mx ); if( res[0] == 0 && res[1] == 0 ) return now; } int low = 0; for( map < int, int > :: iterator it = cnt.begin() ; it != cnt.end() ; it++ ){ if( it -> first != mx ) low += it->second; } while( 1 ){ if( x[now].empty() ) res = ask(now); else res = x[now]; x[now] = res; mx = max(mx, res[0]+res[1]); if( res[0] == 0 && res[1] == 0 ) return now; if( res[0]+res[1] == mx ){ int l = now, r = min(n-1, now + (n-now)/(mx-low+1)); while( l < r ){ int mid = (l+r+1)/2; if( x[mid].empty() ) a = ask(mid), x[mid] = a; else a = x[mid]; if( !a[0] && !a[1] ) return mid; if( res[0] == a[0] && res[1] == a[1] ) l = mid; else r = mid-1; } now = l+1; } else now++, low++; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...