Submission #392475

#TimeUsernameProblemLanguageResultExecution timeMemory
392475my99nBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms332 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++) cwtour[i] = p[i] + i>K?cwtour[i-K]:0; for (int i = N-1; i >= 0; i--) cwwtour[i] = L-p[i] + i+K>=N?cwwtour[i+K]:0; long long ans = 1e18; ans = min(ans, 2*cwtour[N - 1]); ans = min(ans, 2*cwwtour[0]); for (int i = 0; i < N-1; i++) ans = min(ans, 2*cwtour[i]+2*cwwtour[i+1]); if (K < N) { ans = min(ans, L + 2*cwtour[N - K - 1]); ans = min(ans, L + 2*cwwtour[K]); for (int i = 0; i < N-K-1; i++) ans = min(ans, 2*cwtour[i]+2*cwwtour[i+K+1]+L); } if (K >= N) 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...