#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
long long p[100005];
long long cost(int l, int r)
{
int m = (l + r) >> 1;
int med = p[m] - p[m - 1];
return med * (m - l + 1) - (p[m] - p[l - 1]) + p[r] - p[m] - med * (r - m);
}
int besthub(int R, int L, int X[], long long B)
{
for(int i = 0; i < R; i++)
{
p[i] = X[i] + (i > 0 ? p[i - 1] : 0LL);
}
int r = 0;
long long ans = 0;
for(int l = 0; l < R; l++)
{
while(r < R && cost(l, r) <= B)
{
ans = max(ans, cost(l, r));
r++;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |