# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086549 | Pacybwoah | Boxes with souvenirs (IOI15_boxes) | C++17 | 2033 ms | 25792 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 "boxes.h"
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
long long delivery(int N, int K, int L, int p[]) {
vector<int> vec;
for(int i = 0; i < N; i++) if(p[i] > 0) vec.push_back(p[i]);
int n = vec.size();
if(n == 0) return 0;
int k = K;
auto calc = [&](int l, int r){
if(l > r) return 0;
return min(min(vec[r] * 2, (L - vec[l]) * 2), L);
};
vector<ll> dp(n + 1, 1e18);
dp[0] = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j < i; j++){
if(i - j <= k) dp[i] = min(dp[i], dp[j] + calc(j, i - 1));
}
}
return dp[n];
}
// g++ -std=c++17 -o run -Wshadow -Wall -Wextra -fsanitize=undefined -fsanitize=address boxes.cpp grader.cpp
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... |