Submission #621248

#TimeUsernameProblemLanguageResultExecution timeMemory
621248M_WBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
536 ms263204 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; long long cw[10000002], ccw[10000002]; long long delivery(int N, int K, int L, int p[]) { for(int i = 1; i <= N; i++){ if(i - K <= 0) cw[i] = (p[i - 1] * 1ll) << 1; else cw[i] = cw[i - K] + ((p[i - 1] * 1ll) << 1); } for(int i = N; i > 0; i--){ if(i + K > N) ccw[i] = ((L - p[i - 1]) * 1ll) << 1; else ccw[i] = ccw[i + K] + (((L - p[i - 1]) * 1ll) << 1); } long long ans = LLONG_MAX; for(int i = 0; i <= N; i++) ans = min(ans, cw[i] + ccw[i + 1]); for(int i = 0; i + K <= N; i++) ans = min(ans, cw[i] + ccw[i + K + 1] + (L * 1ll)); 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...