This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long long qs[100005],l,r,mid,new_mid,new_val,ans;
int besthub(int n, int m, int x[100005], long long b){
int i;
for(i=n;i>0;i--)x[i]=x[i-1];
x[0]=0;
for(i=1;i<=n;i++)qs[i]=qs[i-1]+x[i];
l=1,r=1,mid=1;
for(l=1;l<=n;l++){
while(1){
if(r==n)break;
new_mid=(l+r+1)/2;
new_val=x[new_mid]*(new_mid-l)-qs[new_mid-1]+qs[l-1]+qs[r+1]-qs[new_mid]-x[new_mid]*(r+1-new_mid);
if(new_val<=b)mid=new_mid,r++;
else break;
}
ans=max(ans,r-l+1);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |