제출 #666288

#제출 시각아이디문제언어결과실행 시간메모리
666288jamezzz선물상자 (IOI15_boxes)C++17
0 / 100
219 ms524288 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define LINF 1023456789123456789 typedef long long ll; #define maxn 10000005 int pfxpv[maxn]; stack<int> sfxpv[maxn]; ll pfx[maxn], sfx[maxn]; ll delivery(int N, int K, int L, int p[]){ sort(p, p + N); for (int i = 0; i < N; ++i) { if (2 * p[i] > L) { sfx[i % K] += (L - p[i]) * 2; } else { sfx[i % K] += L; } } ll ans = LINF; for (int i = 0; i < N; ++i) { if (2 * p[i] < L) { pfx[i % K] += p[i] * 2; sfx[i % K] -= L; } else { pfx[i % K] += L; sfx[i % K] -= (L - p[i]) * 2; } ans = min(ans, pfx[i % K] * 2 + sfx[(i + 1) % K] * 2); } 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...