제출 #205452

#제출 시각아이디문제언어결과실행 시간메모리
205452oscarsierra12커다란 상품 (IOI17_prize)C++14
20 / 100
3034 ms1932 KiB
#include "prize.h" #include <bits/stdc++.h> #define ff first #define ss second using namespace std ; typedef pair<int,int> pii ; map <int,int> mp ; int numLess [ 7 ] ; pii dp [ 200010 ] ; int val [ 7 ] ; int find_best(int n) { int cnt = 1 ; memset ( dp, -1, sizeof dp ) ; while ( 1 ) { int lw = 0, hg = n-1 ; while ( lw < hg ) { int mid = (lw+hg)/2 ; if ( dp[mid].ff == -1 ) { vector <int> ans = ask(mid) ; dp[mid].ff = ans[0] ; dp[mid].ss = ans[1] ; } pii v = dp[mid] ; if ( mp[v.ff+v.ss] == 0 ) { mp[v.ff+v.ss] = cnt ; val[cnt] = v.ff+v.ss ; cnt++ ; } if ( v.ss - numLess[mp[v.ff+v.ss]] == 0 ) hg = mid ; else lw = mid+1 ; } if ( dp[hg].ff == -1 ) { vector <int> ans = ask(hg) ; dp[hg].ff = ans[0] ; dp[hg].ss = ans[1] ; } pii v = dp[hg] ; if ( v.ff + v.ss == 0 ) return hg ; --hg ; if ( dp[hg].ff == -1 ) { vector <int> ans = ask(hg) ; dp[hg].ff = ans[0] ; dp[hg].ss = ans[1] ; } v = dp[hg] ; for ( int i = 1 ; i < 6 ; ++i ) if ( val[i] >= v.ff+v.ss ) numLess[i] += v.ss ; } return n ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...