# include<bits/stdc++.h>
using namespace std;
long long r,l,b,n,pos[100005],w,sum[100005],mid,shua,ans,sn,sm,ri;
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)
{
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;
}
else
{
ri=mid-1;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 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 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
760 KB |
Output is correct |
2 |
Correct |
4 ms |
632 KB |
Output is correct |
3 |
Correct |
18 ms |
2296 KB |
Output is correct |
4 |
Correct |
19 ms |
2364 KB |
Output is correct |
5 |
Incorrect |
10 ms |
1400 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |