제출 #791784

#제출 시각아이디문제언어결과실행 시간메모리
791784jasmin선물상자 (IOI15_boxes)C++17
0 / 100
1 ms212 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; const long long INF=LLONG_MAX; long long delivery(int n, int k, int l, int positions[]) { vector<int> p(n); for(int i=0; i<n; i++){ p[i]=positions[i]; } sort(p.begin(), p.end()); vector<long long> left(n+1); left[0]=0; for(int i=0; i<n; i++){ long long distance = min(p[i], l-p[i]); left[i+1] = left[max(0, i+1-k)] + distance + p[i]; } vector<long long> right(n+1); right[0]=0; for(int i=0; i<n; i++){ long long distance = min(p[i], l-p[i]); right[i+1] = right[max(0, i+1-k)] + distance + l-p[i]; } long long ans=INF; for(int i=0; i<=n; i++){ ans = min(ans, left[i] + right[n-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...