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;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
ll p[100005];
int besthub(int n, int k, int a[], long long b)
{
for (ll i = 0; i<n; i++){
p[i+1] = p[i] + a[i];
}
ll l = 0, r = 0, mx = 0;
while (r < n){
ll mid = (l + r)/2;
ll sum = (p[r+1] - p[mid+1]) - a[mid]*(r-mid) + a[mid]*(mid-l) - (p[mid+1] - p[l+1]);
if (sum <= b){
mx = max(mx, r-l+1);
r++;
}
else {
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... |