#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
long long sum[N];
int besthub(int R, int L, int X[], long long B)
{
for(int i = 1; i <= R; i++) sum[i] = sum[i - 1] + X[i - 1];
int res = 0;
int l = 0, r = R;
while(l <= r) {
int mid = (l + r) >> 1;
int m = mid >> 1;
long long ret = LLONG_MAX;
for(int i = 1; i <= R - mid + 1; i++) {
if(mid == 1) ret = min(ret, 0LL);
if(mid == 2) ret = min(ret, (long long)(X[i + 1] - X[i]));
else {
long long t = sum[i + mid - 1] - sum[i + m] - sum[i + m - 1] + sum[i - 1];
if(mid & 1) ret = min(ret, t);
else ret = min(ret, t + X[i + m - 1]);
}
}
if(ret <= B) res = mid, l = mid + 1;
else r = mid - 1;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
412 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
3 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
600 KB |
Output is correct |
5 |
Correct |
3 ms |
656 KB |
Output is correct |
6 |
Correct |
3 ms |
656 KB |
Output is correct |
7 |
Correct |
2 ms |
656 KB |
Output is correct |
8 |
Correct |
3 ms |
656 KB |
Output is correct |
9 |
Correct |
2 ms |
656 KB |
Output is correct |
10 |
Correct |
3 ms |
656 KB |
Output is correct |
11 |
Correct |
3 ms |
656 KB |
Output is correct |
12 |
Correct |
3 ms |
740 KB |
Output is correct |
13 |
Correct |
3 ms |
740 KB |
Output is correct |
14 |
Correct |
3 ms |
748 KB |
Output is correct |
15 |
Correct |
3 ms |
748 KB |
Output is correct |
16 |
Correct |
2 ms |
748 KB |
Output is correct |
17 |
Correct |
2 ms |
748 KB |
Output is correct |
18 |
Correct |
3 ms |
748 KB |
Output is correct |
19 |
Correct |
3 ms |
748 KB |
Output is correct |
20 |
Correct |
2 ms |
748 KB |
Output is correct |
21 |
Correct |
3 ms |
748 KB |
Output is correct |
22 |
Correct |
3 ms |
748 KB |
Output is correct |
23 |
Correct |
3 ms |
748 KB |
Output is correct |
24 |
Correct |
4 ms |
748 KB |
Output is correct |
25 |
Correct |
3 ms |
748 KB |
Output is correct |
26 |
Correct |
3 ms |
748 KB |
Output is correct |
27 |
Correct |
5 ms |
748 KB |
Output is correct |
28 |
Correct |
4 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |