# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
519614 | silverfish | Boxes with souvenirs (IOI15_boxes) | C++17 | 2059 ms | 213600 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"
using namespace std;
using ll = long long;
const int N = 10000007;
ll dp[N], s[N];
set<array<ll,2>> st;
inline ll mn(ll a, ll b){
return (a < b ? a : b);
}
long long delivery(int n, int k, int L, int p[]) {
ll l = L;
fill(dp, dp+N, 1e18+10);
// sort(p, p+n);
for(int i = 0; i < n; ++i){
s[i] = (i ? dp[i-1] : 0) + mn(2LL*(l-p[i]), l);
st.insert({s[i], i});
if(i-k >= 0) st.erase(st.find({s[i-k], i-k}));
auto it = st.begin();
int pos = (*it)[1];
dp[i] = dp[pos-1]+mn(l, mn(2LL*p[i], 2LL*(l-p[pos])));
}
return dp[n-1];
}
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... |