제출 #996516

#제출 시각아이디문제언어결과실행 시간메모리
996516Alfraganus선물상자 (IOI15_boxes)C++17
100 / 100
551 ms236840 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long ll delivery(int n, int k, int l, int p[]) { sort(p, p + n); vector<int> q; for(int i = 0; i < n; i ++) if(p[i] != 0) q.push_back(p[i]); n = (int)q.size(); auto get = [&](ll x) {return min(x, l - x);}; vector<ll> pref(n + 1), suff(n + 1); for(int i = 0; i < n; i ++) pref[i + 1] = (i + 1 < k ? 0 : pref[i + 1 - k]) + q[i] + get(q[i]); for(int i = n - 1; i >= 0; i --) suff[i] = (i + k > n ? 0 : suff[i + k]) + l - q[i] + get(q[i]); ll ans = 1e18; for(int i = 0; i <= n; i ++) ans = min(ans, pref[i] + suff[i]); 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...