제출 #424395

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
4243952021-06-11 21:49:23SuhaibSawalha1선물상자 (IOI15_boxes)C++17
20 / 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, A[N], A2[N], KS = 0;
for (int i = 0; i < N; ++i) {
if (i % K == 0 && i) {
KS += min(2 * p[i - 1], L);
}
A[i] = KS + min(2 * p[i], L);
}
KS = 0;
for (int i = N - 1; ~i; --i) {
if ((N - i - 1) % K == 0 && i < N - 1) {
KS += min(2 * (L - p[i + 1]), L);
}
A2[i] = KS + min(2 * (L - p[i]), L);
}
ans = min({A[N - 1], A2[0], K == N ? L : A[N - K - 1] + L});
for (int i = 0; i + K - 1 < N; ++i) {
ans = min(ans, A[i] + A2[i + K - 1] + L);
}
for (int i = 0; i < N - 1; ++i) {
ans = min(ans, A[i] + A2[i + 1]);
}
return ans;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...