#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
} // namespace
int besthub(int R, int L, int X[], long long B)
{
vector<long> pref(R + 1, 0), suff(R + 1, 0);
for (int i = 0; i < R; i++)
pref[i + 1] = pref[i] + X[i];
for (int i = R - 1; i >= 0; i--)
suff[i] = suff[i + 1] - X[i];
int res = 0;
for (int i = 0; i < R; i++)
{
int lo = i, hi = R;
while (lo < hi)
{
int mid = (lo + hi + 1) / 2;
int m = (i + mid - 1) / 2;
if (pref[mid] - pref[i] + (long)(2 * m - i - mid) * X[m] <= B)
lo = mid;
else
hi = mid - 1;
}
res = max(res, lo - i);
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |