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)
{
int ans = 0;
for(int i = 0; i < R; i++){
int l = i - 1, r = i + 1, cnt = 1, cst = 0;
while(l >= 0 || r < R){
if(l < 0 || (r != R && X[i] - X[l] > X[r] - X[i])){
if(X[r] - X[i] + cst > B)break;
cst += X[r] - X[i];
r++;
}
else{
if(X[i] - X[l] + cst > B)break;
cst += X[i] - X[l];
l--;
}
cnt++;
}
ans = max(ans, cnt);
}
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... |