# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341030 | 12tqian | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 384 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 "boxes.h"
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 2e9;
long long delivery(int N, int K, int L, int p[]) {
using namespace std;
vector<ll> pre(N);
for (int i = 0; i < N ; i++)
pre[i] = (i?pre[i-1]:0) + p[i];
auto get = [&](int l, int r) -> ll {
return pre[r] - (l?pre[l-1]:0);
};
auto range = [&](int l, int r) -> int {
ll res = INF;
int mx = -INF;
int mn = INF;
for (int i = l; i <= r; i++) {
mx = max(mx, p[i]);
mn = min(mn, p[i]);
}
res = min(res, 2LL * mx);
res = min(res, 2LL * (L - mn));
res = min(res, (ll) L);
return res;
};
ll ans = 1e18;
auto solve = [&]() {
ll res = 0;
for (int l = 0; l < N; l += K) {
int r = l+K-1;
r = min(r, N-1);
res += range(l, r);
}
ans = min(ans, res);
};
solve();
reverse(p, p+N);
solve();
return ans;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |