제출 #416466

#제출 시각아이디문제언어결과실행 시간메모리
416466kevinxiehk선물상자 (IOI15_boxes)C++17
100 / 100
596 ms372236 KiB
#include "boxes.h" #include "bits/stdc++.h" #define lint long long using namespace std; long long delivery(int n, int k, int l, int p[]) { lint le[n + 5], lcnt = 0; lint ri[n + 5], rcnt = 0; lint ii = 0; while(ii < n && p[ii] <= l / 2) { le[lcnt] = p[ii]; lcnt++; ii++; } while(ii < n) { ri[rcnt] = l - p[ii]; rcnt++; ii++; } reverse(ri, ri + rcnt); lint ll[lcnt + 5], rr[rcnt + 5]; ll[0] = 0, rr[0] = 0; for(int i = 1; i <= lcnt; i++) { ll[i] = (i <= k ? le[i - 1] * 2 : ll[i - k] + le[i - 1] * 2); } for(int i = 1; i <= rcnt; i++) { rr[i] = (i <= k ? ri[i - 1] * 2 : rr[i - k] + ri[i - 1] * 2); } lint ans = ll[lcnt] + rr[rcnt]; for(int i = 0; i <= k; i++) { int lef = i; int rig = k - i; ans = min(ans, l + ll[max(0LL, lcnt - lef)] + rr[max(0LL, rcnt - rig)]); } 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...