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;
#define ll long long
ll pref[100003];
ll pos[100003];
ll cost(ll l, ll p){
ll med=(l+p)/2;
return pref[p]-pref[l-1]-(p-l+1)*pos[med];
}
ll besthub(int n, int L, int x[], ll bud){
for (ll i = 0; i<n; i++){
pos[i+1]=x[i];
pref[i+1]=pref[i]+x[i];
}
ll mx=1,p=1;
for (ll l = 1; l<=n; l++){
while(p<n && cost(l,p+1)<=bud)p++;
mx=max(mx,p-l+1);
}
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... |