#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
long long qs[N];
bool solve(int mid,int n,long long t) {
long long l,r;
for (int i=(mid+1)/2;i+mid/2<=n;i++) {
if (mid%2) l = qs[i-1] - qs[max(0, i-mid/2-1)];
else l = qs[i] - qs[max(0, i-mid/2)];
r = qs[i+mid/2] - qs[i];
if (r - l <= t) return true;
}
return false;
}
int besthub(int n,int m,int x[],long long t) {
for (int i=0;i<n;i++) qs[i+1] = qs[i] + x[i];
int l = 1 , r = n , ans = 0;
while (l <= r) {
int mid = (l + r) / 2;
if (solve(mid, n, t)) l = mid + 1 , ans = mid;
else r = mid - 1;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2392 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2392 KB |
Output is correct |
24 |
Correct |
0 ms |
2396 KB |
Output is correct |
25 |
Correct |
0 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2404 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2496 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2500 KB |
Output is correct |
24 |
Correct |
1 ms |
2504 KB |
Output is correct |
25 |
Correct |
1 ms |
2500 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
2 ms |
2648 KB |
Output is correct |
3 |
Correct |
8 ms |
3496 KB |
Output is correct |
4 |
Correct |
8 ms |
3676 KB |
Output is correct |
5 |
Correct |
4 ms |
2904 KB |
Output is correct |
6 |
Correct |
4 ms |
2908 KB |
Output is correct |
7 |
Correct |
7 ms |
3420 KB |
Output is correct |
8 |
Correct |
7 ms |
3420 KB |
Output is correct |
9 |
Correct |
4 ms |
2908 KB |
Output is correct |
10 |
Correct |
4 ms |
2908 KB |
Output is correct |
11 |
Correct |
8 ms |
3676 KB |
Output is correct |
12 |
Correct |
8 ms |
3552 KB |
Output is correct |
13 |
Correct |
4 ms |
2908 KB |
Output is correct |
14 |
Correct |
4 ms |
2904 KB |
Output is correct |
15 |
Correct |
6 ms |
3364 KB |
Output is correct |
16 |
Correct |
6 ms |
3420 KB |
Output is correct |
17 |
Correct |
8 ms |
3416 KB |
Output is correct |
18 |
Correct |
7 ms |
3368 KB |
Output is correct |
19 |
Correct |
8 ms |
3676 KB |
Output is correct |
20 |
Correct |
8 ms |
3628 KB |
Output is correct |