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 typedef li;
int besthub(int n, int m, int x[], li b)
{
int mx=0,l=0,r=0; li t=0;
for (int i=0;i<n;i++) if (t+(x[i]-x[0])<=b) t+=(x[i]-x[0]),r++;
for (int i=1;i<n;i++)
{
t+=(2*i-l-r)*(x[i]-x[i-1]);
while (t>b) t-=(x[i]-x[l]),l++;
while (r<n && t+(x[r]-x[i])<=b) t+=(x[r]-x[i]),r++;
mx=max(mx,r-l);
}
return mx;
}
# | 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... |