Submission #584658

#TimeUsernameProblemLanguageResultExecution timeMemory
584658BlagojceRice Hub (IOI11_ricehub)C++11
0 / 100
2 ms340 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B) { //but did you try long long? long long temp_budget = 0; int len = 1; int ans = 0; int l = 0, r = 0; for(int i = 0; i < R; i ++){ if(r < i){ r = i; l = i; len = 1; } if(i - l > r - i){ temp_budget -= X[i] - X[l]; --len; ++l; } bool change = true; while(change){ change = false; if(i - l < r - i){ if(l > 0 && temp_budget + X[i] - X[l-1] <= B){ temp_budget += X[i] - X[l-1]; ++len; --l; change = true; } } else{ if(r + 1 < R && temp_budget + X[r+1] - X[i] <= B){ temp_budget += X[r+1] - X[i]; ++len; ++r; change = true; } } } ans = max(ans, len); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...