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;
int besthub(int n, int L, int X[], long long B){
int res = 0;
for(int i = 0; i < n; i ++){
int l = i, r = i;
long long ans = 0;
while(l >= 0 && r < n){
if(l > 0 && r < n - 1){
int x = X[i] - X[l - 1];
int y = X[r + 1] - X[i];
if(x < y && ans + x <= B){
l --;
ans += x;
}
else if(y <= x && ans + y <= B){
r ++;
ans += y;
}
}
else if(l > 0 && ans + (X[i] - X[l - 1]) <= B){
ans += (X[i] - X[l - 1]);
l --;
}
else if(r < n - 1 && ans + (X[r + 1] - X[i]) <= B){
ans += (X[r + 1] - X[i]);
r ++;
}
else break;
}
res = max(res, r - l + 1);
}
return res;
}
# | 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... |