#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int n, int L, int a[], long long cmax) {
vector<int> s(n + 1);
for (int i = 1; i < n; ++i)
s[i] = s[i - 1] + a[i - 1];
int ans = 0;
for (int i = 1, j = 1; i <= n; ++i) {
auto cost = [&](int l, int r) {
int m = (l + r) / 2;
return 1LL * (m - l) * a[m - 1] - (s[m - 1] - s[i - 1]) + s[r] - s[m] - 1LL * (r - m) * a[m - 1];
};
while (j + 1 <= n && cost(i, j + 1) <= cmax)
++j;
ans = max(ans, j - i + 1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |