#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll cnt[100005];
bool check(int n, int pos, ll lim){
int l, r, md;
ll rs;
for(int i=1; i<=n-pos+1; i++){
l=i; r=i+pos-1;
md=(l+r)>>1;
rs=(cnt[r]-cnt[md])-(cnt[md-pos%2]-cnt[l-1]);
if(rs<=lim) return true;
}
return false;
}
int besthub(int R, int L, int* X, ll B){
for(int i=1; i<=R; i++)
cnt[i]=cnt[i-1]+X[i-1];
int l=0, r=R;
while(l!=r){
int md=(l+r+1)>>1;
if(check(R, md, B)) l=md;
else r=md-1;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
292 KB |
Output is correct |
5 |
Correct |
2 ms |
400 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
404 KB |
Output is correct |
16 |
Correct |
2 ms |
372 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
380 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
380 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
376 KB |
Output is correct |
25 |
Correct |
3 ms |
504 KB |
Output is correct |
26 |
Correct |
3 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
19 ms |
2556 KB |
Output is correct |
4 |
Correct |
18 ms |
2552 KB |
Output is correct |
5 |
Correct |
9 ms |
1272 KB |
Output is correct |
6 |
Correct |
9 ms |
1272 KB |
Output is correct |
7 |
Correct |
16 ms |
2296 KB |
Output is correct |
8 |
Correct |
15 ms |
2296 KB |
Output is correct |
9 |
Correct |
9 ms |
1244 KB |
Output is correct |
10 |
Correct |
9 ms |
1276 KB |
Output is correct |
11 |
Correct |
20 ms |
2552 KB |
Output is correct |
12 |
Correct |
20 ms |
2552 KB |
Output is correct |
13 |
Correct |
10 ms |
1272 KB |
Output is correct |
14 |
Correct |
10 ms |
1272 KB |
Output is correct |
15 |
Correct |
16 ms |
2040 KB |
Output is correct |
16 |
Correct |
17 ms |
2168 KB |
Output is correct |
17 |
Correct |
19 ms |
2356 KB |
Output is correct |
18 |
Correct |
19 ms |
2296 KB |
Output is correct |
19 |
Correct |
19 ms |
2424 KB |
Output is correct |
20 |
Correct |
19 ms |
2424 KB |
Output is correct |