제출 #70553

#제출 시각아이디문제언어결과실행 시간메모리
70553mr_banana선물상자 (IOI15_boxes)C++17
10 / 100
2 ms376 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; const int MN=1e7+10; pair<long long,int> dp[MN]; long long delivery(int n, int k, int l, int p[]) { sort(p,p+n); dp[0]={2*p[0],k-1}; for(int i=1;i<n;i++){ dp[i]=dp[i-1]; if(dp[i-1].second){ dp[i].second--; dp[i].first+=2*(p[i]-p[i-1]); } else{ dp[i].second=k-1; dp[i].first+=2*p[i]; } } pair<long long,int> ans1={0,0}; long long ans=1e18; for(int i=n-1;i>=0;i--){ ans=min(dp[i].first+ans1.first,ans); if(ans1.second){ ans1.second--; ans1.first+=2*(p[i+1]-p[i]); } else{ ans1.second=k-1; ans1.first+=2*(l-p[i]); } } ans=min(ans,ans1.first); 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...