이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |