Submission #992423

#TimeUsernameProblemLanguageResultExecution timeMemory
992423phoenixBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms348 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int n, int k, int L, int p[]) { long long res = 0; int l = -1, r = n; while (l + 1 < n && p[l + 1] * 2 < L) l++; while (r - 1 >= 0 && (L - p[r - 1]) * 2 < L) r--; if (l + 1 < r) { res += L; for (int i = 0; i < min(k - 1, n - 1); i++) { int a1 = (l >= 0 ? p[l] : -1), a2 = (r < n ? p[r] : -1); if (a1 >= a2) { l--; } else { r++; } } } while (l >= 0) { res += 2 * p[l]; l -= k; } while (r < n) { res += 2 * (L - p[r]); r += k; } return res; }
#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...