Submission #392477

#TimeUsernameProblemLanguageResultExecution timeMemory
392477my99nBoxes with souvenirs (IOI15_boxes)C++14
70 / 100
486 ms173776 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long cwtour[1000100], cwwtour[1000100]; long long delivery(int N, int K, int L, int p[]) { for (int i = 0; i < N; i++) { if (i < K) cwtour[i] = p[i]; else cwtour[i] = cwtour[i - K] + p[i]; } for (int i = N - 1; i >= 0; i--) { if (i >= N - K) cwwtour[i] = L - p[i]; else cwwtour[i] = cwwtour[i + K] + L - p[i]; } long long ans = min(2 * cwtour[N - 1], 2 * cwwtour[0]); for (int i = 1; i < N; i++) ans = min(ans, 2 * cwtour[i - 1] + 2 * cwwtour[i]); if (K < N) { ans = min(ans, L + 2 * cwwtour[K]); ans = min(ans, L + 2 * cwtour[N - K - 1]); for (int i = 1; i + K < N; i++) ans = min(ans, 2 * cwtour[i - 1] + L + 2 * cwwtour[i + K]); } else { ans = min(ans, (long long) L); } 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...