# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
914232 | Itamar | Boxes with souvenirs (IOI15_boxes) | C++14 | 597 ms | 257208 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.
using namespace std;
#define ll long long
#include <vector>
#define vi vector<int>
#include <algorithm>
#define vll vector<ll>
ll delivery(int N, int K, int L, int positions[]) {
K = min(K, N);
ll ans = 1e18;
vi v1, v2;
for (int i = 0; i < N; i++) {
if (positions[i] <= L / 2)v1.push_back(positions[i]);
else v2.push_back(L - positions[i]);
}
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
int s1 = v1.size(), s2 = v2.size();
vll dp1(1+s1), dp2(1+s2);
for (int i = 1; i <= min(s1,K); i++) {
dp1[i] = 2*v1[i - 1];
}
for (int i = K + 1; i <= s1; i++) {
dp1[i] = 2*v1[i - 1] + dp1[i - K];
}
for (int i = 1; i <= min(s2, K); i++) {
dp2[i] = 2 * v2[i - 1];
}
for (int i = K + 1; i <= s2; i++) {
dp2[i] = 2 * v2[i - 1] + dp2[i - K];
}
ans = dp1[s1] + dp2[s2];
for (int i = 0; i <= K; i++) {
ans = min(ans,L+dp1[max(0,s1 - i)] + dp2[max(0,s2 - K + i)]);
}
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... |