#ifndef KienVu
#include "ricehub.h"
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int besthub(int R, int L, int X[], ll B) {
vector<ll> pref(R + 1);
for (int i = 0; i < R; ++i) pref[i + 1] = pref[i] + X[i];
auto cost = [&](int l, int r) {
int md = (l + r) >> 1;
return ll(md + 1 - l) * X[md] - (pref[md + 1] + pref[l]) - (r - md) * X[md] + (pref[r + 1] - pref[md + 1]);
};
int ans = 0;
int r = 0;
for (int l = 0; l < R; ++l) {
while (r + 1 < R && cost(l, r + 1) <= B) r++;
ans = max(ans, r - l + 1);
}
return ans;
}
#ifdef KienVu
int main() {
int R, L, B;
while (cin >> R >> L >> B) {
int X[R];
for (int i = 0; i < R; ++i) cin >> X[i];
cout << besthub(R, L, X, B) << "\n";
}
}
#endif // KienVu
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |