Submission #139438

#TimeUsernameProblemLanguageResultExecution timeMemory
139438bogdan10bosBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
2 ms380 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] = min(2LL * p[i], 1LL * L); if(i >= K) pfx[i] += pfx[i - K]; } for(int i = N - 1; i >= 0; i--) { sfx[i] = min(2LL * (L - p[i]), 1LL * L); 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]); 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...