Submission #28926

#TimeUsernameProblemLanguageResultExecution timeMemory
28926NikeforRice Hub (IOI11_ricehub)C++98
100 / 100
23 ms5020 KiB
#include "ricehub.h" #include<algorithm> int besthub(int R, int L, int X[], long long B) { int optimalGain=0; int m, l, r; l = r = m = 0; long long spent = 0; int localGain = 1; while(1) { if(r!=(R-1))r++; else break; spent+= X[r]-X[m]; m = (r+l+1)/2; if(spent>B) { optimalGain = std::max(optimalGain, localGain); while(spent>B) { spent+= X[l]-X[m]; l++; m = (r+l+1)/2; localGain--; } } localGain++; } optimalGain = std::max(optimalGain, localGain); return optimalGain ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...