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 ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
int besthub(int n, int L, int X[], long long b)
{
ll a[n],ans=0,pre[n+1];
pre[0]=0;
for(int i=0;i<n;i++){
a[i]=X[i];
pre[i+1]=pre[i]+a[i];
}
for(int i=0;i<n;i++){
ll l=0,r=min(i,n-1-i);
while(l<r){
ll m=(l+r+1)/2;
if(pre[i+m+1]-pre[i+1]-(pre[i]-pre[i-m])<=b)l=m;
else r=m-1;
}
ans=max(ans,2*l+1);
l=0,r=min(i+1,n-1-i);
while(l<r){
ll m=(l+r+1)/2;
if(pre[i+m+1]-pre[i+1]-(pre[i+1]-pre[i-m+1])<=b)l=m;
else r=m-1;
}
ans=max(ans,2*l);
}
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... |