# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81679 | wzy | Boxes with souvenirs (IOI15_boxes) | C++11 | 8 ms | 376 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;
long long dpL[10000001] , dpR[10000001];
long long delivery(int N, int K, int L, int p[]) {
#define int long long
int ans = (int) 1e18;
int k = K;
int n = N;
int l = L;
for(int i = 0 ; i < N ;i ++){
dpL[i] = 2*p[i];
if(i >= K) dpL[i] = dpL[i-k] + 2*p[i]; // pick the last block and then solve for [0 , i-k]
}
for(int j = N - 1 ; j >= 0 ; j--){
int u = j + K ;
dpR[j] = 2*(L - p[j]);
if(u <= n - 1) dpR[j] = dpR[u] + 2*(L - p[j]);
}
for(int j = N - 1 ; j >= 0 ; j--){
for(int r = 0 ; (j - k*r + 1) >= 0 ; r++){
int u = j - k*r + 1;
if(u > j) continue;
ans = min(ans ,dpL[u] + dpR[j] + L*((j-u+1)/k + ((j-u+1)%k ? 1 : 0)));
}
ans = min(ans , dpR[j] + L*((j)/k + (j%k ? 1 : 0)));
int i = j;
ans = min(ans ,dpL[j] + L *((n-i-1)/k + ((n-i-1)%k ? 1 : 0)));
}
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... |