#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];
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] - 2 * pref[m] + pref[i] + (long)(2 * m - i - mid) * X[m] <= B)
lo = mid;
else
hi = mid - 1;
}
res = max(res, lo - i);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
288 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
308 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
596 KB |
Output is correct |
2 |
Correct |
3 ms |
596 KB |
Output is correct |
3 |
Correct |
14 ms |
2260 KB |
Output is correct |
4 |
Correct |
13 ms |
2228 KB |
Output is correct |
5 |
Correct |
9 ms |
1236 KB |
Output is correct |
6 |
Correct |
7 ms |
1236 KB |
Output is correct |
7 |
Correct |
14 ms |
2260 KB |
Output is correct |
8 |
Correct |
18 ms |
2260 KB |
Output is correct |
9 |
Correct |
11 ms |
1292 KB |
Output is correct |
10 |
Correct |
8 ms |
1176 KB |
Output is correct |
11 |
Correct |
16 ms |
2260 KB |
Output is correct |
12 |
Correct |
14 ms |
2216 KB |
Output is correct |
13 |
Correct |
7 ms |
1236 KB |
Output is correct |
14 |
Correct |
8 ms |
1236 KB |
Output is correct |
15 |
Correct |
11 ms |
1748 KB |
Output is correct |
16 |
Correct |
11 ms |
1720 KB |
Output is correct |
17 |
Correct |
15 ms |
2072 KB |
Output is correct |
18 |
Correct |
12 ms |
2004 KB |
Output is correct |
19 |
Correct |
13 ms |
2076 KB |
Output is correct |
20 |
Correct |
19 ms |
2132 KB |
Output is correct |