#include "ricehub.h"
#include<bits/stdc++.h>
const int N = 2e5 + 5;
#define ll long long
using namespace std;
ll a[N], pre[N], n, m, x, y;
ll calc(int x, int y) {
ll ans = 0;
int t = (x + y) / 2;
ans += (t-x+1) * a[t] - pre[t] + pre[x-1];
ans += pre[y] - pre[t] - (y-t) * a[t];
return ans;
}
int besthub(int R, int L, int X[], long long B) {
n = R;
for(int i = 1; i <= n; i++) {
a[i] = X[i-1];
pre[i] = pre[i-1] + a[i];
}
int j = 0, ans = 0;
ll p = B;
for(int i = 1; i <= n; i++) {
while(calc(i, j+1) <= p && j + 1 <= n) j++;
ans = max(ans, j - i + 1);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8752 KB |
Output is correct |
2 |
Correct |
0 ms |
8752 KB |
Output is correct |
3 |
Correct |
0 ms |
8752 KB |
Output is correct |
4 |
Correct |
0 ms |
8752 KB |
Output is correct |
5 |
Correct |
0 ms |
8752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8752 KB |
Output is correct |
2 |
Correct |
0 ms |
8752 KB |
Output is correct |
3 |
Correct |
0 ms |
8752 KB |
Output is correct |
4 |
Correct |
1 ms |
8752 KB |
Output is correct |
5 |
Correct |
0 ms |
8752 KB |
Output is correct |
6 |
Correct |
0 ms |
8752 KB |
Output is correct |
7 |
Correct |
0 ms |
8752 KB |
Output is correct |
8 |
Correct |
0 ms |
8752 KB |
Output is correct |
9 |
Correct |
0 ms |
8752 KB |
Output is correct |
10 |
Correct |
0 ms |
8752 KB |
Output is correct |
11 |
Correct |
0 ms |
8752 KB |
Output is correct |
12 |
Correct |
0 ms |
8752 KB |
Output is correct |
13 |
Correct |
0 ms |
8752 KB |
Output is correct |
14 |
Correct |
0 ms |
8752 KB |
Output is correct |
15 |
Correct |
0 ms |
8752 KB |
Output is correct |
16 |
Correct |
0 ms |
8752 KB |
Output is correct |
17 |
Correct |
0 ms |
8752 KB |
Output is correct |
18 |
Correct |
0 ms |
8752 KB |
Output is correct |
19 |
Correct |
0 ms |
8752 KB |
Output is correct |
20 |
Correct |
0 ms |
8752 KB |
Output is correct |
21 |
Correct |
0 ms |
8752 KB |
Output is correct |
22 |
Correct |
0 ms |
8752 KB |
Output is correct |
23 |
Correct |
0 ms |
8752 KB |
Output is correct |
24 |
Correct |
0 ms |
8752 KB |
Output is correct |
25 |
Correct |
0 ms |
8752 KB |
Output is correct |
26 |
Correct |
0 ms |
8752 KB |
Output is correct |
27 |
Correct |
0 ms |
8752 KB |
Output is correct |
28 |
Correct |
0 ms |
8752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8752 KB |
Output is correct |
2 |
Correct |
0 ms |
8752 KB |
Output is correct |
3 |
Correct |
0 ms |
8752 KB |
Output is correct |
4 |
Correct |
0 ms |
8752 KB |
Output is correct |
5 |
Correct |
0 ms |
8752 KB |
Output is correct |
6 |
Correct |
0 ms |
8752 KB |
Output is correct |
7 |
Correct |
0 ms |
8752 KB |
Output is correct |
8 |
Correct |
0 ms |
8752 KB |
Output is correct |
9 |
Correct |
0 ms |
8752 KB |
Output is correct |
10 |
Correct |
0 ms |
8752 KB |
Output is correct |
11 |
Correct |
0 ms |
8752 KB |
Output is correct |
12 |
Correct |
0 ms |
8752 KB |
Output is correct |
13 |
Correct |
0 ms |
8752 KB |
Output is correct |
14 |
Correct |
0 ms |
8752 KB |
Output is correct |
15 |
Correct |
1 ms |
8752 KB |
Output is correct |
16 |
Correct |
0 ms |
8752 KB |
Output is correct |
17 |
Correct |
0 ms |
8752 KB |
Output is correct |
18 |
Correct |
0 ms |
8752 KB |
Output is correct |
19 |
Correct |
0 ms |
8752 KB |
Output is correct |
20 |
Correct |
0 ms |
8752 KB |
Output is correct |
21 |
Correct |
0 ms |
8752 KB |
Output is correct |
22 |
Correct |
0 ms |
8752 KB |
Output is correct |
23 |
Correct |
1 ms |
8752 KB |
Output is correct |
24 |
Correct |
0 ms |
8752 KB |
Output is correct |
25 |
Correct |
0 ms |
8752 KB |
Output is correct |
26 |
Correct |
0 ms |
8752 KB |
Output is correct |
27 |
Correct |
0 ms |
8752 KB |
Output is correct |
28 |
Correct |
0 ms |
8752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8752 KB |
Output is correct |
2 |
Correct |
0 ms |
8752 KB |
Output is correct |
3 |
Correct |
28 ms |
8752 KB |
Output is correct |
4 |
Correct |
18 ms |
8752 KB |
Output is correct |
5 |
Correct |
12 ms |
8752 KB |
Output is correct |
6 |
Correct |
12 ms |
8752 KB |
Output is correct |
7 |
Correct |
0 ms |
8752 KB |
Output is correct |
8 |
Correct |
17 ms |
8752 KB |
Output is correct |
9 |
Correct |
9 ms |
8752 KB |
Output is correct |
10 |
Correct |
9 ms |
8752 KB |
Output is correct |
11 |
Correct |
22 ms |
8752 KB |
Output is correct |
12 |
Correct |
22 ms |
8752 KB |
Output is correct |
13 |
Correct |
10 ms |
8752 KB |
Output is correct |
14 |
Correct |
0 ms |
8752 KB |
Output is correct |
15 |
Correct |
13 ms |
8752 KB |
Output is correct |
16 |
Correct |
11 ms |
8752 KB |
Output is correct |
17 |
Correct |
11 ms |
8752 KB |
Output is correct |
18 |
Correct |
17 ms |
8752 KB |
Output is correct |
19 |
Correct |
27 ms |
8752 KB |
Output is correct |
20 |
Correct |
13 ms |
8752 KB |
Output is correct |