Submission #725815

#TimeUsernameProblemLanguageResultExecution timeMemory
725815TheSahibBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms308 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; ll delivery(int N, int K, int M, int p[]) { ll L[N + 1], R[N + 1]; L[0] = 0; for (int i = 1; i <= N; i++) { L[i] = L[(i - 1) / K * K] + p[i - 1] * 2; } R[0] = 0; for (int i = 1; i <= N; i++) { R[i] = R[(i - 1) / K * K] + (M - p[N - i]) * 2; } ll ans = 1e18; for (int i = 0; i <= N; i++) { ans = min(ans, L[i] + R[N - i]); if(N - i - K >= 0){ ans = min(ans, L[i] + R[N - i - K] + M); } } 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...