제출 #139437

#제출 시각아이디문제언어결과실행 시간메모리
139437bogdan10bos선물상자 (IOI15_boxes)C++14
10 / 100
2 ms404 KiB
/// ? #include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long LL; LL delivery(int N, int K, int L, int p[]) { sort(p, p + N); int cnt0 = 0; for(int i = 0; i < N; i++) if(p[i] == 0) cnt0++; if(cnt0) { for(int i = cnt0; i < N; i++) p[i - cnt0] = p[i]; N -= cnt0; } vector<LL> pfx(N + 5), sfx(N + 5); for(int i = 0; i < N; i++) { pfx[i] = p[i]; if(i >= K) pfx[i] += pfx[i - K]; } for(int i = N - 1; i >= 0; i--) { sfx[i] = (L - p[i]); if(i + K < N) sfx[i] += sfx[i + K]; } LL ans = 1LL << 60; for(int i = 0; i < N; i++) ans = min(ans, pfx[i] + sfx[i + 1]); ans *= 2LL; 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...