Submission #621245

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