///100 poena
#include <bits/stdc++.h>
#include "ricehub.h"
#define ll long long
using namespace std;
const int N=100009;
ll niz[N],pref[N],suf[N];
int besthub(int R, int L, int X[], long long B){
int n=R;
for(int i=0; i<n; i++) niz[i+1]=X[i];
for(int i=1; i<=n; i++) pref[i]=pref[i-1]+niz[i];
for(int i=n; i>0; i--) suf[i]=suf[i+1]+1000000000-niz[i];
int rez=0;
for(int i=1; i<=n; i++){
int l=i,d=n;
while(l<=d){
int S=l+d>>1;
int s=i+S>>1;
ll val=0;
val+=pref[S]-pref[s]-(S-s)*niz[s];
val+=suf[i]-suf[s]-(s-i)*(1000000000-niz[s]);
if(val<=B){
rez=max(rez,S-i+1);
l=S+1;
}
else
d=S-1;
}
}
return rez;
}
# | 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... |