Submission #588380

#TimeUsernameProblemLanguageResultExecution timeMemory
588380lorenzoferrari선물상자 (IOI15_boxes)C++17
10 / 100
441 ms8200 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using LL = long long; const LL inf = 1e18; LL solve(int n, int k, int l, vector<int> p) { vector<vector<LL>> dp(n+1, vector<LL>(n+1, inf)); dp[0][0] = 0; for (int a = 0; a <= n; ++a) { for (int b = 0; a + b <= n; ++b) { for (int s = 1; s <= k && s <= a; ++s) { dp[a][b] = min(dp[a][b], dp[a - s][b] + p[a - 1]); } for (int s = 1; s <= k && s <= b; ++s) { dp[a][b] = min(dp[a][b], dp[a][b - s] + l - p[n - b]); } } } LL ans = 1e18; for (int i = 0; i <= n; ++i) { ans = min(ans, dp[i][n - i]); } return 2 * ans; } LL delivery(int n, int k, int l, int p[]) { sort(p, p + n); vector<int> v; // those you don't take greedily for (int i = 0; i < n; ++i) { v.push_back(p[i]); } return solve(n, k, l, v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...