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;
long long int a[300005];
long long int su[300005];
long long int cal(int ll,int rr)
{
int len = rr - ll +1;
if(len %2 == 0)
{
int suf = (ll+rr+1) / 2;
long long int ans = su[rr] - su[suf-1] - su[suf-1] + su[ll-1];
return ans;
}
else
{
int mid = (ll+rr)/2;
long long int ans = su[rr] - su[mid] - su[mid-1] + su[ll-1];
return ans;
}
}
int besthub(int R, int L, int X[], long long B)
{
for(int i=1;i<=R;i++)a[i] = X[i-1];
for(int i=1;i<=R;i++)su[i] = su[i-1] + a[i];
int l = 1;
int r = 1;
int maxnlen = -1;
while(r<=R)
{
if(cal(l,r) > B)l++;
else
{
maxnlen = max(maxnlen,r-l+1);
r++;
}
}
return maxnlen;
}
# | 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... |