This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |