Submission #158345

#TimeUsernameProblemLanguageResultExecution timeMemory
158345WLZRice Hub (IOI11_ricehub)C++14
100 / 100
28 ms2580 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { long long T[R + 1]; T[0] = 0; for (int i = 1; i <= R; i++) { T[i] = T[i - 1] + X[i - 1]; } int ans = 1; for (int s = 0; s < R; s++) { int lo = s, hi = R - 1; while (lo <= hi) { int t = lo + (hi - lo) / 2; int p = s + (t - s) / 2; long long cost = (p - s) * X[p] - (T[p] - T[s]) + (T[t + 1] - T[p + 1]) - (t - p) * X[p]; if (cost <= B) { ans = max(ans, t - s + 1); lo = t + 1; } else { hi = t - 1; } } } 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...