제출 #1232508

#제출 시각아이디문제언어결과실행 시간메모리
123250812baater선물상자 (IOI15_boxes)C++20
0 / 100
0 ms328 KiB
#include "boxes.h"
#include <algorithm>

long long delivery(int N, int K, int L, int p[]) {

    int maxUnder = 0, minOver = 2000000000;
    for (int i = 0; i < N; i++) {
        if (p[i] > L/2) {
            minOver = std::min(minOver, p[i]);
        } else {
            maxUnder = std::max(maxUnder, p[i]);
        }
    }

    long long total = 0;
    if (p[N-1] <= L/2) {
        total = p[N-1] * 2;
    } else if (p[0] > L/2) {
        total = (L - p[0]) * 2;
    } else {
        total = L;
    }
    return std::min(total, static_cast<long long>(2*maxUnder + 2*(L-minOver)));

}
#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...