Submission #423294

#TimeUsernameProblemLanguageResultExecution timeMemory
423294SuhaibSawalha1Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms296 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long ans, D[N] = {}, D2[N] = {}; int l = 0; for (int i = 0; i < N; ++i) { if (i % K == 0) { l = 0; } D[i] = 2 * (p[i] - l); if (i) { D[i] += D[i - 1]; } l = p[i]; } l = L; for (int i = N - 1; ~i; --i) { if ((N - i) % K == 0) { l = L; } D2[i] = 2 * (l - p[i]); if (i < N - 1) { D2[i] += D2[i + 1]; } l = p[i]; } ans = min(D[N - 1], D2[0]); for (int i = 0; i < N - 1; ++i) { ans = min(ans, D[i] + D2[i + 1]); } 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...