이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], ll B)
{
int ans = 1;
vector<ll> Sum(R, 0);
for (int i = 1; i < R; i++)
Sum[i] = Sum[i - 1] + X[i] - X[0];
for (int i = 0; i < R; i++)
{
int c1 = i, c2 = R - 1;
while (c1 <= c2)
{
int m = (c1 + c2) / 2;
int hub = (i + m) / 2;
ll S = 0;
S += 1LL * (X[hub] - X[i]) * (hub - i + 1) - (Sum[hub] - Sum[i] - 1LL * (hub - i) * (X[i] - X[0]));
S += Sum[m] - Sum[hub] - 1LL * (m - hub) * (X[hub] - X[0]);
if (S <= B)
{
ans = max(ans, m - i + 1);
c1 = m + 1;
}
else
c2 = m - 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... |