이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int N = 100005;
int n, d;
int x[N];
ll b;
ll p[N];
bool stg(int q)
{
for (int l = 1; l <= n - q + 1; ++l)
{
int r = l + q - 1;
int m = (l + r) / 2;
ll yb = 0;
yb += (m - l + 1) * 1LL * x[m];
yb -= (p[m] - p[l - 1]);
yb += (p[r] - p[m - 1]);
yb -= (r - m + 1) * 1LL * x[m];
if (yb <= b)
return true;
}
return false;
}
int solv()
{
for (int i = 1; i <= n; ++i)
p[i] = p[i - 1] + x[i];
int ans = 0;
int l = 1, r = n;
while (l <= r)
{
int m = (l + r) / 2;
if (stg(m))
{
ans = m;
l = m + 1;
}
else
{
r = m - 1;
}
}
return ans;
}
int besthub(int R, int L, int X[], ll B)
{
n = R;
d = L;
for (int i = 1; i <= n; ++i)
x[i] = X[i - 1];
b = B;
return solv();
}
# | 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... |