#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxN=1e5+5;
ll sum[maxN+1];
int a[maxN+1];
ll get(ll l,ll r)
{
return sum[r]-sum[l-1];
}
ll besthub(int L,int n,int x[],ll B)
{
for(int i=0;i<n;i++)
{
a[i+1]=x[i];
}
sum[0]=0;
for(int i=1;i<=n;i++)
{
sum[i]=sum[i-1]+a[i];
}
ll res=0;
for(int len=1;len<=n;len++)
{
ll l=1,r=len;
while(r<=n)
{
ll p=(l+r)/2;
ll cur=(p-l)*a[p]-get(l,p-1)+get(p+1,r)-(r-p)*a[p];
if(cur<=B)
{
res=max(res,1LL*len);
}
l++;
r++;
}
}
return res;
}
/*int main()
{
int L,n;
ll B;
cin>>n>>L>>B;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<besthub(L,n,a,B);
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
86 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
2652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |