# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933795 | raul2008487 | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 348 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>
#include "boxes.h"
#define ll int
#define in insert
#define pb push_back
#define vl vector<ll>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;
const ll inf = 100000000000;
long long delivery(int N, int K, int L, int p[]) {
ll n = N, k = K, ans = inf, i, j;
vl dpp(n + 2), dps(n + 2);
dpp[0] = dps[n + 1] = 0;
for(i = 1; i <= n; i++){
ll pr = max(i - k, 0);
dpp[i] = dpp[pr] + p[i - 1] + min(L - p[i - 1], p[i - 1]);
}
for(i = n; i > 0; i--){
ll nxt = min(i + k, n + 1);
dps[i] = dps[nxt] + (L - p[i - 1]) + min(L - p[i - 1], p[i - 1]);
}
for(i = 0; i <= n; i++){
ans = min(ans, (dpp[i] + dps[i + 1]));
}
return ans;
}
/*int main(){
ll n = 3, k = 2, l = 8;
ll p[3] = {1, 2, 5};
cout << delivery(n, k, l, p) << endl;
}*/
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... |