#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807
vector<int> p1;
vector<int> DP;
int cost(int a, int b, int c){
int ans = c;
ans = min(ans, (c-(a-1))*2);
ans = min(ans, b*2);
return ans;
}
int f(int n, int l, int k){
if(DP[n] != INF) return DP[n];
int ans = INF;
for(int i = 1; i < k; i++){
ans = min(ans, f(n-i, l, k)+cost(p1[n-i],p1[n],l));
}
DP[n] = ans;
return ans;
}
#undef int long long
long long delivery(int N, int K, int L, int p[]) {
#define int long long
DP.assign(N+1, INF);
for(int i = 0; i < N; i++){
p1.push_back(p[i]);
}
return f(N,L,K);
}
/*
signed main(){
int N, K, L;
cin >> N >> K >> L;
int tab[N];
DP.resize(N);
for(int i = 0; i < N; i++){
cin >> tab[i];
}
#undef int long long
cout << delivery(N,K,L,tab) << endl;
}
*/
Compilation message
boxes.cpp:26:12: warning: extra tokens at end of #undef directive
#undef int long long
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |