제출 #424397

#제출 시각아이디문제언어결과실행 시간메모리
424397SuhaibSawalha1선물상자 (IOI15_boxes)C++17
0 / 100
1 ms204 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], N == K ? L : L + D[N - K - 1]}); for (int i = 0; i + K - 1 < N - 1; ++i) { ans = min(ans, D[i] + D2[i + K - 1] + L); } 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...