Submission #1298340

#TimeUsernameProblemLanguageResultExecution timeMemory
1298340the_commando_xBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms576 KiB
#include "boxes.h" #include <algorithm> long long delivery(int N, int K, int L, int p[]) { auto dist = [&](long long x) { return std::min(x, (long long)L - x); }; long long ans = 0; if (K == 1) for (int i = 0; i < N; ++i) ans += 2LL * std::max(0ll, dist(p[i])); else if (K == N) { ans = std::min({(long long)L, 2LL * p[N - 1], 2LL * (L - p[0])}); long long split1 = 0, split2 = 0; int i = (int)(std::lower_bound(p, p + N, L / 2) - p); if (i > 0) split1 = p[i - 1]; if (i < N) split2 = L - p[i]; ans = std::min(ans, 2 * (split1 + split2)); } return ans; }
#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...