# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592731 | Mahtimursu | Rice Hub (IOI11_ricehub) | C++17 | 1079 ms | 1208 KiB |
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 "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int besthub(int R, int L, int X[], long long B) {
vector<ll> lft;
vector<ll> rgt;
int best = 0;
int n = R;
for (int i = n - 1; i > 0; --i) {
rgt.push_back(X[i]);
}
for (int i = 0; i < n; ++i) {
ll leftm = B;
int cur = 0;
int li = lft.size() - 1;
int ri = 0;
vector<ll> dst;
for (int j = 0; j < n; ++j) dst.push_back(abs(X[i] - X[j]));
sort(dst.begin(), dst.end());
int idx = 0;
while (idx < n && dst[idx] <= leftm) {
leftm -= dst[idx++];
cur++;
}
/*while (true) {
ll leftd = li >= 0 ? abs(lft[li] - X[i]) : 1e18;
ll rightd = ri < (int)rgt.size() ? abs(rgt[ri] - X[i]) : 1e18;
if (min(leftd, rightd) > leftm) break;
cur++;
if (leftd < rightd) {
leftm -= leftd;
li--;
} else {
leftm -= rightd;
ri++;
}
}*/
best = max(best, cur);
lft.push_back(X[i]);
rgt.pop_back();
}
return best;
}
Compilation message (stderr)
# | 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... |