# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
301817 | square1001 | Boxes with souvenirs (IOI15_boxes) | C++14 | 610 ms | 255060 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 <vector>
#include <algorithm>
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
vector<int> pl, pr;
for(int i = 0; i < N; ++i) {
if(p[i] * 2 <= L) {
pl.push_back(p[i]);
}
else {
pr.push_back(L - p[i]);
}
}
reverse(pr.begin(), pr.end());
int NL = pl.size(), NR = pr.size();
vector<long long> dpl(NL + 1), dpr(NR + 1);
for(int i = 0; i < NL; ++i) {
dpl[i + 1] = dpl[max(i - K + 1, 0)] + pl[i];
}
for(int i = 0; i < NR; ++i) {
dpr[i + 1] = dpr[max(i - K + 1, 0)] + pr[i];
}
long long ans = dpl[NL] * 2 + dpr[NR] * 2;
for(int i = 0; i <= NL; ++i) {
int t = N - i - K;
if(0 <= t && t <= NR) {
ans = min(ans, dpl[i] * 2 + dpr[t] * 2 + L);
}
}
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... |