이 제출은 이전 버전의 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]);
auto pos = fields.begin(), lt = fields.begin(), rt = fields.begin() + 1;
ll cur = 0;
if (n == 1) return 1;
long output = 0;
while (rt != fields.end())
{
while (cur > b)
{
cur -= *pos - *lt;
lt++;
}
while (rt != fields.end() && cur + (*rt - *pos) <= b)
{
cur += (*rt - *pos);
rt++;
}
while (rt != fields.end() && (*pos - *lt) > (*rt - *pos))
{
cur += (*rt - *pos) - (*pos - *lt);
lt++, rt++;
while (rt != fields.end() && cur + (*rt - *pos) <= b)
{
cur += (*rt - *pos);
rt++;
}
}
// cout << lt - fields.begin() << " " << pos - fields.begin() << " " << rt - fields.begin() << "\n";
output = max(output, ((rt - fields.begin()) - (lt - fields.begin())));
pos++;
if (rt != fields.end())
{
// cout << "c";
// cout << cur << " ";
cur += (*pos - *(pos - 1)) * ((pos - fields.begin()) - (lt - fields.begin()));
// cout << cur << " ";
cur += (*(pos - 1) - *pos) * ((rt - fields.begin()) - (pos - fields.begin()));
// cout << cur << "\n";
}
}
// cerr << output << "\n";
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... |