Submission #594387

#TimeUsernameProblemLanguageResultExecution timeMemory
594387FatihSolakThe Big Prize (IOI17_prize)C++17
20 / 100
84 ms5280 KiB
#include "prize.h" #include <bits/stdc++.h> #define N 200005 using namespace std; vector<int> rem[N]; int tot_queries = 10000; vector<int> get(int x){ if(rem[x].size())return rem[x]; //assert(tot_queries--); return rem[x] = ask(x); } const int block = 256; int find_best(int n){ if(n <= 5000){ for(int i = 0;i<n;i++){ if(get(i)[0] + get(i)[1] == 0){ return i; } } } long long maxi = 0; int point = 0; while((maxi * maxi + 1) * (maxi * maxi + 1) + 1 < n){ maxi = max(maxi,(long long)get(point)[0] + get(point)[1]); point++; if(point == 500)break; } int p = 0; while(1){ int now = get(p)[0] + get(p)[1]; if(now != maxi){ if(now == 0){ return p; } } else{ int pos = p - get(p)[0]; int l = p,r= n-1; while(l + block < n){ int m = l + block; int val = get(m)[0] + get(m)[1]; if(val != maxi || m - get(m)[0] != pos + (m-p)){ break; } else l = m; } r = min(r,l + block - 1); while(l < r){ int m = (l + r + 1)/2; int val = get(m)[0] + get(m)[1]; if(val != maxi || m - get(m)[0] != pos + (m-p)){ r = m-1; } else l = m; } p = l; } p++; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...