# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154793 | 2019-09-24T16:14:10 Z | Mercenary | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 ms | 0 KB |
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 1e7 + 5; ll a[maxn] , b[maxn]; ll res = 1e18; ll delivery(int n , int k , int L, vector<int> P) { for(int i = 1 ; i <= n; ++i) a[i] = a[max(0, i- k)] + P[i - 1] + min(P[i - 1] , L - P[i - 1]); for(int i = n ; i >= 1; --i) b[i] = b[min(n + 1, i + k)]+ L - P[i - 1] + min(P[i - 1] , L - P[i - 1]); for(int i = 0 ; i <= n ; i++)res = min(res , a[i] + b[i + 1]); return res; }