# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080607 | anonymous321 | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 360 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>
using namespace std;
typedef long long ll;
const ll INF = numeric_limits<ll>::max()/4;
ll delivery(int n, int k, int l, int apos []) {
vector<int> pos (apos, apos + n);
vector<ll> minl (n+2, INF); // excl
minl[0] = 0;
for (int i = 0; i < n; i++) {
minl[i+1] = minl[(i/k) * k] + pos[i]*2;
}
vector<ll> minlm (n+2, INF);
minlm[0] = 0;
int id = 0;
for (int i = 0; i < n; i++) {
for (int j = id; j < n; j++) { // incl. for minl
ll x = minl[j+1] + ceil((i - j)/ (double) k) * l;
if (x <= minlm[i+1]) {
minlm[i+1] = x;
id = j;
} else {
break;
}
}
}
vector<ll> minr (n+1, INF); // incl
minr[n] = 0;
for (int i = n-1; i >= 0; i--) {
minr[i] = minr[ceil(i/(double) k) * k] + (l - pos[i]) * 2;
}
ll sol = INF;
for (int i = 0; i < n; i++) { // incl r
ll x = minlm[i] + minr[i+1];
sol = min(sol, x);
}
return sol;
}
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... |