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>
#define MAXN 100005
typedef long long ll;
using namespace std;
static int N; ll X[MAXN],S[MAXN];
ll f(int s,int e)
{
int t = (s+e)/2;
return S[e] - S[t] - X[t]*(e-t) +(t-s) *X[t] - (S[t-1]-S[s-1]);
}
int besthub(int n, int L, int x[], ll B)
{
N = n ;
for(int i=0;i<N;i++) X[i+1] = x[i];
for(int i=1;i<=N;i++) S[i] = S[i-1] + X[i];
int s=1, e = 1,ans=-1987654321;
while(1)
{
while(s+1<=e && f(s,e)>B) s++;
ans = max(ans,e-s+1);
e++;
if(e>N) break;
}
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... |