# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782601 | ymm | Boxes with souvenirs (IOI15_boxes) | C++17 | 727 ms | 196412 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>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
vector<ll> al, dpl, ar, dpr;
long long delivery(int N, int K, int L, int p[]) {
Loop (i,0,N) {
if (p[i] > L-p[i])
ar.push_back(L-p[i]);
else
al.push_back(p[i]);
}
sort(al.begin(), al.end());
sort(ar.begin(), ar.end());
Loop (dard,0,2) {
auto &a = dard? ar: al;
auto &dp = dard? dpr: dpl;
dp.resize(a.size()+1);
dp[0] = 0;
Loop (i,0,a.size())
dp[i+1] = i < K? 2*a[i]: 2*a[i] + dp[i+1-K];
}
ll ans = dpl.back() + dpr.back();
Loop (i,0,K) {
int x = (int)al.size()-i;
int y = (int)ar.size()-K+i;
if (x < 0 || y < 0)
continue;
ans = min(ans, dpl[x] + dpr[y] + 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... |