Submission #1081961

#TimeUsernameProblemLanguageResultExecution timeMemory
1081961raphael_heuchlBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
67 ms29704 KiB
#include "boxes.h" #include <vector> #include <algorithm> #include <map> #include <iostream> #define INF 1'000'000'000'000'000'000 std::vector<long long> people; long long n, l, k; long long dist(long long curr) { return std::min(l - people[curr], people[curr]); } long long dp[1005]; long long delivery(int N, int K, int L, int p[]) { n = N, k = K, l = L; people.push_back(0); for (int i = 0; i < N; ++i) people.push_back(p[i]); std::sort(people.begin(), people.end()); for (int j = K-1; j >= 0; --j) dp[j] = dist(N); for (int i = N-1; i >= 0; --i) { long long var = dp[K-1]; for (int j = K-1; j >= 0; --j) { long long optionA = j ? std::abs(people[i] - people[i + 1]) + dp[j-1] : INF; long long optionB = dist(i) + dist(i+1) + var; dp[j] = std::min(optionA, optionB); } } return dp[K - 1]; }
#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...