이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
int besthub(int n, int L, int X[], long long b)
{
vector <ll> fields;
for (int i = 0; i < n; i++) fields.emplace_back(X[i]);
ll cur = 0;
if (n == 1) return 1;
int output = 0;
ll p;
int left, right;
for (int i = 0; i < n; i++)
{
p = fields[i];
cur = b;
left = i - 1, right = i + 1;
while (true)
{
if (left < 0 && right == n)
{
break;
} else if (left < 0)
{
if (cur >= fields[right] - p) {
cur -= fields[right] - p;
right++;
} else break;
} else if (right == n)
{
if (cur >= p - fields[left]) {
cur -= p - fields[left];
left--;
} else break;
}
else if (p - fields[left] < fields[right] - p)
{
if (cur >= p - fields[left]) {
cur -= p - fields[left];
left--;
} else break;
} else {
if (cur >= fields[right] - p) {
cur -= fields[right] - p;
right++;
} else break;
}
}
output = max(output, right - left - 1);
}
return output;
}
# | 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... |