Submission #835217

#TimeUsernameProblemLanguageResultExecution timeMemory
835217oscar1fThe Big Prize (IOI17_prize)C++17
90 / 100
84 ms11396 KiB
#include<bits/stdc++.h> #include "prize.h" using namespace std; const int MAX_VAL=200*1000+5; int nbVal,nbPasMax,rep,nbTest; vector<pair<int,int>> interCour,interNouv; vector<int> memo[MAX_VAL]; void calc(int deb,int fin,int nbGau,int nbDro) { if (fin<deb or nbGau+nbDro==nbPasMax) { return; } int mid=(deb+fin)/2; vector<int> ans; if (memo[mid][0]==-1) { ans=ask(mid); memo[mid]=ans; } else { ans=memo[mid]; } if (ans[0]+ans[1]<nbPasMax) { if (ans[0]+ans[1]==0) { rep=mid; } calc(deb,mid-1,nbGau,ans[1]+1); calc(mid+1,fin,ans[0]+1,nbDro); } else { calc(deb,mid-1,nbGau,ans[1]); calc(mid+1,fin,ans[0],nbDro); } } int find_best(int n) { nbVal=n; for (int i=0;i<nbVal;i++) { memo[i]={-1,-1}; } nbTest=500; int deb,fin,mid; vector<int> ans; interCour.push_back({0,nbVal-1}); while (!interCour.empty() and nbTest>0) { interNouv.clear(); for (auto i:interCour) { deb=i.first; fin=i.second; mid=(deb+fin)/2; if (nbTest>0) { nbTest--; ans=ask(mid); memo[mid]=ans; nbPasMax=max(nbPasMax,ans[0]+ans[1]); if (mid-1>=deb) { interNouv.push_back({deb,mid-1}); } if (mid+1<=fin) { interNouv.push_back({mid+1,fin}); } } } interCour=interNouv; } calc(0,nbVal-1,0,0); return rep; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...