#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
int ans = 0;
int l = 0;
int r = 1;
for (int i = 0; i < R; i++) {
if (i > 0) {
B -= 1ll * (X[i] - X[i - 1]) * (i - l);
B += 1ll * (X[i] - X[i - 1]) * (r - i);
}
while (l < i && B < 0) {
B += X[i] - X[l];
l++;
}
while (r < R && B >= X[r] - X[i]) {
B -= X[r] - X[i];
r++;
}
while (r < R && B + X[i] - X[l] >= X[r] - X[i] && X[i] - X[l] >= X[r] - X[i]) {
B += 1ll * X[i] - X[l] - X[r] + X[i];
r++;
l++;
}
assert(r > i);
ans = max(ans, r - l);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
272 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
448 KB |
Output is correct |
3 |
Correct |
15 ms |
676 KB |
Output is correct |
4 |
Correct |
14 ms |
588 KB |
Output is correct |
5 |
Correct |
6 ms |
460 KB |
Output is correct |
6 |
Correct |
7 ms |
460 KB |
Output is correct |
7 |
Correct |
12 ms |
652 KB |
Output is correct |
8 |
Correct |
12 ms |
588 KB |
Output is correct |
9 |
Correct |
8 ms |
496 KB |
Output is correct |
10 |
Correct |
6 ms |
460 KB |
Output is correct |
11 |
Correct |
14 ms |
692 KB |
Output is correct |
12 |
Correct |
18 ms |
692 KB |
Output is correct |
13 |
Correct |
7 ms |
380 KB |
Output is correct |
14 |
Correct |
7 ms |
496 KB |
Output is correct |
15 |
Correct |
10 ms |
592 KB |
Output is correct |
16 |
Correct |
11 ms |
588 KB |
Output is correct |
17 |
Correct |
12 ms |
588 KB |
Output is correct |
18 |
Correct |
13 ms |
588 KB |
Output is correct |
19 |
Correct |
13 ms |
660 KB |
Output is correct |
20 |
Correct |
14 ms |
664 KB |
Output is correct |