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 <bits/stdc++.h>
using namespace std;
long long pref[100005];
int besthub(int n, int m, int a[], long long b)
{
pref[0]=a[0];
for (long long i=1; i<n; i++)
pref[i]=pref[i-1]+a[i];
long long ans=0;
for (long long i=0; i<n; i++)
{
long long l=i, r=n-1;
while (l<r)
{
long long mid=(l+r+1)/2;
if (pref[mid]-pref[(i+mid)/2]-pref[(i+mid-1)/2]+(i==0?0:pref[i-1])<=b)
l=mid;
else
r=mid-1;
}
ans=max(ans, l-i+1);
}
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... |