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;
using ll = long long;
int besthub(int R, int L, int X[], long long B) {
ll s;
int ans = 0, mn, l, r;
for (int i = 0; i + 1 < R; i ++) {
l = i;
r = i + 1;
s = 0;
while (l >= 0 && r < R && s + (X[r]- X[l]) <= B) {
s += (X[r] - X[l]);
l --;
r ++;
}
mn = INT_MAX;
if ( l >= 0) {
mn = min(mn, X[i] - X[l]);
}
if ( r < R) {
mn = min(mn, X[r] - X[i + 1]);
}
if (mn + s <= B) {
ans = max(ans, r - l);
}
else ans = max(ans, r - l - 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... |