# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668896 | Astrayt | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 212 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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define All(x) x.begin(), x.end()
ll delivery(int N, int K, int L, int pos[]){
ll ans = 0;
vector<ll> lp, rp;
for(int i = 0; i < N; ++i){
if(pos[i] == 0) continue;
if(pos[i] <= L / 2) lp.pb(pos[i]);
else rp.pb(L - pos[i]);
}
reverse(rp.begin(), rp.end());
int lN = lp.size(), rN = rp.size();
vector<ll> dpl(lN + 1, 0), dpr(rN + 1, 0);
for(int i = 1; i <= lN; ++i){
if(i - K < 0) dpl[i] = lp[i - 1] * 2;
else dpl[i] = dpl[i - K] + lp[i - 1] * 2;
}
for(int i = 1; i <= rN; ++i){
if(i - K < 0) dpr[i] = rp[i - 1] * 2;
else dpr[i] = dpr[i - K] + rp[i - 1] * 2;
}
ans = dpl[lN] + dpr[rN];
for(int i = 0; i <= K; ++i){
int iL = lN - i, iR = rN - K + i;
if(iL < 0 || iR < 0) continue;
ans = min(ans, dpl[iL] + dpr[iR] + 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... |