Submission #411185

#TimeUsernameProblemLanguageResultExecution timeMemory
411185LouayFarahRice Hub (IOI11_ricehub)C++14
0 / 100
359 ms488 KiB
#include "bits/stdc++.h" #include "ricehub.h" using namespace std; long long S(int X[], int h, int l, int r) { long long sum = 0; for(int i = l; i<r; i++) sum = sum + abs(h-X[l]); return sum; } int besthub(int R, int L, int X[], long long B) { //int l = 0, r = R-1; int res = 0; for(int k = 1; k<=R; k++) { int l = 0; int r = k; while(r<=R) { int mid = l + (r-l)/2; int h = X[mid]; long long curr = S(X, h, l, r); if(curr<=B) res = max(res, k); r++, l++; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...