제출 #992428

#제출 시각아이디문제언어결과실행 시간메모리
992428phoenixBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
0 ms348 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int n, int k, int ll, int p[]) { long long L = ll; 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--; int cnt = r - l - 1; res += cnt / k * L; cnt %= k; if (cnt) { res += L; for (int i = 0; i < k - cnt; i++) { int a1 = (l >= 0 ? p[l] : -1), a2 = (r < n ? p[r] : -1); if (max(a1, a2) == -1) break; 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...