Submission #429211

#TimeUsernameProblemLanguageResultExecution timeMemory
429211Dremix10The Big Prize (IOI17_prize)C++17
20 / 100
3064 ms7344 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define endl '\n' #define F first #define S second #define all(x) (x).begin(),(x).end() const int N = 3e5+1; const ll INF = 2e18; const int MOD = 1e9+7; vector<int> ask(int i); vector<vector<int> > memo(N); const int block = 5; int nn; int queried = 0; vector<int> askme(int i){ if(memo[i].empty()){ queried++; assert(queried <= 10000); memo[i] = ask(i); } return memo[i]; } map<int,int> seen; int go(int b){ for(int i=b*block;i<min(nn,(b+1)*block);i++){ vector<int> arr = askme(i); if(arr[0] + arr[1] == 0) return i; seen[arr[0]+arr[1]]++; } return -1; } int find_best(int n) { /// the second to smallest price is in at most 450 boxes /// the maximum amount of prizes is 5 nn = n; int blocks = (n+4)/5; int L = 0,R = blocks-1; while(L<=R){ int l = L,r = R; while(l<=r){ int mid = (l+r)/2; int pos = mid*block; vector<int> arr = askme(pos); int low = arr[0],high = arr[1]; if(low + high == 0) return pos; int tot = 0; for(auto x : seen){ if(x.F > high+low)break; tot += x.S; } if(low - tot > 0) r = mid-1; else l = mid+1; } int ans = go(r); if(ans != -1) return ans; L = r+1; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:79:1: warning: control reaches end of non-void function [-Wreturn-type]
   79 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...