제출 #291459

#제출 시각아이디문제언어결과실행 시간메모리
291459Berted선물상자 (IOI15_boxes)C++14
35 / 100
1 ms384 KiB
#include "boxes.h" #include <iostream> #include <assert.h> #include <utility> #include <algorithm> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long res = 0; int i, j, Lsz = 0, Rsz = 0; for (i = 0; i < N && p[i] <= L / 2; i++); for (i--; i >= 0 && p[i]; i--) { Lsz++; if (Lsz == K) {res += 2 * p[i + K - 1]; Lsz = 0;} } for (j = N - 1; j >= 0 && p[j] > L / 2; j--); for (j++; j < N; j++) { Rsz++; if (Rsz == K) {res += 2 * (L - p[j - K + 1]); Rsz = 0;} } long long temp = 0; if (Lsz) {temp += 2 * p[i + Lsz];} if (Rsz) {temp += 2 * (L - p[j - Rsz]);} res += min(temp, (long long)(Lsz + Rsz + K - 1) / K * L); 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...