#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x[100005],k,s[100005];
bool check(int m){
ll l=1,r=m;
for(ll i=1;i<=n;i++){
while(abs(x[r+1]-x[i])<abs(x[i]-x[l]))l++,r++;
if((s[r]-s[i])-(r-i)*x[i]+(i-l+1)*x[i]-(s[i]-s[l-1])<=k)return true;
}
return false;
}
int besthub(int R,int L,int*X,ll B){
n=R,k=B;
for(int i=1;i<=n;i++)x[i]=X[i-1],s[i]+=s[i-1],s[i]+=x[i];
x[n+1]=2000000000;
int l=1,r=n+1;
while(r-l>1){
int m=(l+r)/2;
if(check(m))l=m;
else r=m;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
2 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
512 KB |
Output is correct |
26 |
Correct |
3 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
896 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
17 ms |
3292 KB |
Output is correct |
4 |
Correct |
19 ms |
3320 KB |
Output is correct |
5 |
Correct |
11 ms |
1664 KB |
Output is correct |
6 |
Correct |
11 ms |
1664 KB |
Output is correct |
7 |
Correct |
14 ms |
3072 KB |
Output is correct |
8 |
Correct |
16 ms |
3072 KB |
Output is correct |
9 |
Correct |
10 ms |
1664 KB |
Output is correct |
10 |
Correct |
10 ms |
1624 KB |
Output is correct |
11 |
Correct |
18 ms |
3320 KB |
Output is correct |
12 |
Correct |
19 ms |
3328 KB |
Output is correct |
13 |
Correct |
15 ms |
1664 KB |
Output is correct |
14 |
Correct |
15 ms |
1664 KB |
Output is correct |
15 |
Correct |
14 ms |
2560 KB |
Output is correct |
16 |
Correct |
15 ms |
2560 KB |
Output is correct |
17 |
Correct |
16 ms |
3064 KB |
Output is correct |
18 |
Correct |
18 ms |
2944 KB |
Output is correct |
19 |
Correct |
17 ms |
3200 KB |
Output is correct |
20 |
Correct |
19 ms |
3192 KB |
Output is correct |