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 "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=50005;
ll a[sz], b[sz], d[sz], p[sz];
int besthub(int num, int le, int x[], long long k)
{
for(int i=0; i<num; i++){
p[i+1]=p[i]+x[i];
}
ll l=1, r=num, ans=0;
while(l<=r){
ll mid=(l+r)/2;
ll num=x[mid-1]*(mid-l)-p[mid-1]+p[l-1]+p[r]-p[mid]-x[mid-1]*(r-mid);
//cout<<l<<' '<<r<<' '<<num<<' '<<p[r-1]-p[mid-1]<<endl;
if(num<=k){
ans=max(ans, r-l+1);
r--;
}
else{
l++;
}
}
return ans;
}
/*
{} []
5 20 6
1
2
10
12
14
3
1 3 13 25 39
12*2-10+39-13-12*1=12+16
*/
# | 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... |