# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261573 | sandoval | Rice Hub (IOI11_ricehub) | C++11 | 249 ms | 1536 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;
using ll = long long;
struct Info{int l, r; ll cost;};
int besthub(int R, int L, int X[], long long B) {
const int n = R;
vector<ll> pre(X, X+n);
for (int i = 1; i < n; ++i) pre[i] += pre[i-1];
auto sum = [](const vector<ll>& ps, int l, int r)->long long{
if (l > r) return 0LL;
ll ans = ps[r];
if (l > 0) ans -= ps[l-1];
return ans;
};
auto get = [&sum, &n](int A[], int idx, int l, int r, const vector<ll>& ps)->Info{
int lb = lower_bound(A, A+n, l) - A;
int ub = upper_bound(A, A+n, r) - A - 1;
int le = 1+idx-lb;
int g = ub-idx;
return Info{lb, ub, 1LL*A[idx]*le-sum(ps, lb, idx) + sum(ps, 1+idx, ub)-1LL*g*A[idx]};
};
auto getleft = [&sum, &n](int p, int l, int r, const vector<ll>& ps)->ll{
# | 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... |