제출 #371016

#제출 시각아이디문제언어결과실행 시간메모리
371016peijar선물상자 (IOI15_boxes)C++17
100 / 100
1326 ms450464 KiB
#include "boxes.h" #include <bits/stdc++.h> #define SZ(v) ((int)(v).size()) using namespace std; using ll = long long; ll delivery(int N, int K, int L, int p[]) { ll sol(1e18); vector<ll> increasing(N), decreasing(N); for (int i(0); i < N; ++i) increasing[i] = decreasing[i] = p[i]; sort(increasing.begin(), increasing.end()); sort(decreasing.rbegin(), decreasing.rend()); vector<ll> getInc(N), getDec(N); for (int i(0); i < N; ++i) { getInc[i] = 2 * increasing[i]; getDec[i] = 2 * (L - decreasing[i]); if (i >= K) { getInc[i] += getInc[i-K]; getDec[i] += getDec[i-K]; } } for (int takeInc(0); takeInc <= N; ++takeInc) { ll cost(0); if (takeInc) cost += getInc[takeInc-1]; if (takeInc < N) cost += getDec[N - takeInc-1]; sol = min(sol, cost); } for (int takeInc(0); takeInc < N; ++takeInc) { ll cost(0); if (takeInc) cost += getInc[takeInc-1]; cost += L; if (takeInc + K < N) cost += getDec[N - takeInc - K - 1]; sol = min(sol, cost); } return sol; }
#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...