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>
#include "ricehub.h"
using namespace std;
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int besthub(int R, int L, int X[], long long B)
{
long long P[R+5];
P[0] = X[0];
for(int i = 1; i < R; i++)P[i] = X[i] + P[i - 1];
int ans = 0;
for(int i = 0; i < R; i++){
int lo = i, hi = R - 1, tmp = lo;
while(lo <= hi){
int mid = (lo + hi) >> 1;
long long med = X[(i + mid) >> 1];
if(P[mid] - P[(i + mid) >> 1] - med * (mid - ((i + mid) >> 1)) + med * (((i + mid) >> 1) - i + 1) - (P[(i + mid) >> 1] - (i > 0 ? P[i-1] : 0)) <= B)tmp = mid, lo = mid + 1;
else hi = mid - 1;
}
ans = max(ans, tmp - 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... |