제출 #67840

#제출 시각아이디문제언어결과실행 시간메모리
67840gnoor선물상자 (IOI15_boxes)C++17
0 / 100
2 ms376 KiB
#include "boxes.h" #include <algorithm> using namespace std; int posl[10000100]; int posr[10000100]; int cntl; int cntr; long long dpl[10000100]; long long dpr[10000100]; long long delivery(int N, int K, int L, int p[]) { int m=L/2; for (int i=0;i<N;i++) { if (p[i]<=m) { posl[cntl++]=p[i]; } else { posr[cntr++]=L-p[i]; } } reverse(posr,posr+cntr); for (int i=0;i<min(cntl,K);i++) { dpl[i]=posl[i]*2; } for (int i=K;i<cntl;i++) { dpl[i]=dpl[i-K]+posl[i]*2; } for (int i=0;i<min(cntr,K);i++) { dpr[i]=posr[i]*2; } for (int i=K;i<cntr;i++) { dpr[i]=dpr[i-K]+posr[i]*2; } long long ans=1e16; int x; if (cntl<=K) x=cntl-1; else x=K; for (int i=0;i<=x;i++) { ans=min(ans,dpl[cntl-i-1]+((cntr-(K-i)-1<0)?0:dpr[cntr-(K-i)-1])+L); } 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...