# include<bits/stdc++.h>
using namespace std;
long long r,l,b,n,pos[100005],w,sum[100005],mid,shua,ans,sn,sm,ri,yy;
long long besthub(int r,int l, int x[],long long b)
{
// cin>>r>>l>>b;
for (long long i=1; i<=r; i++)
{
pos[i]=x[i-1];
w+=pos[i];
sum[i]=w;
}
l=1;
ri=r;
while (l<=ri)
{
yy=0;
mid=(l+ri+1)/2;
for (long long i=1; i<=r-mid+1; i++)
{
// cout<<i<<" "<<l<<" "<<pos[l]<<" "<<ri<<" "<<pos[ri]<<" "<<mid<<" "<<pos[mid]<<endl;
shua=(i+i+mid)/2;
sn=sum[shua-1]-sum[i-1];
sm=sum[i+mid-1]-sum[shua];
if ((pos[shua]*(shua-i)-sn)+sm-(pos[shua]*(i+mid-1-shua))<=b)
{
ans=mid;
l=mid+1;
yy=1;
}
}
if (yy==0) ri=mid-1;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 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 |
380 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 |
376 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 |
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 |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
4 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 |
404 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 |
376 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 |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
508 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
3 ms |
504 KB |
Output is correct |
26 |
Correct |
3 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
504 KB |
Output is correct |
28 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
764 KB |
Output is correct |
2 |
Correct |
6 ms |
892 KB |
Output is correct |
3 |
Correct |
18 ms |
3320 KB |
Output is correct |
4 |
Correct |
18 ms |
3320 KB |
Output is correct |
5 |
Correct |
11 ms |
1628 KB |
Output is correct |
6 |
Correct |
11 ms |
1656 KB |
Output is correct |
7 |
Correct |
16 ms |
3064 KB |
Output is correct |
8 |
Correct |
16 ms |
3132 KB |
Output is correct |
9 |
Correct |
11 ms |
1528 KB |
Output is correct |
10 |
Correct |
12 ms |
1528 KB |
Output is correct |
11 |
Correct |
21 ms |
3324 KB |
Output is correct |
12 |
Correct |
20 ms |
3320 KB |
Output is correct |
13 |
Correct |
13 ms |
1656 KB |
Output is correct |
14 |
Correct |
13 ms |
1656 KB |
Output is correct |
15 |
Correct |
16 ms |
2552 KB |
Output is correct |
16 |
Correct |
16 ms |
2680 KB |
Output is correct |
17 |
Correct |
18 ms |
2936 KB |
Output is correct |
18 |
Correct |
19 ms |
3064 KB |
Output is correct |
19 |
Correct |
19 ms |
3196 KB |
Output is correct |
20 |
Correct |
19 ms |
3192 KB |
Output is correct |