제출 #185909

#제출 시각아이디문제언어결과실행 시간메모리
185909TAISA_선물상자 (IOI15_boxes)C++14
0 / 100
15 ms376 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; using ll=long long; const ll LINF=(1LL<<60)-1LL; long long delivery(int N, int K, int L, int p[]) { ll res=LINF; if(N>1000){ return 0; } sort(p,p+N); int st=-1; for(int i=0;i<N;i++){ if(p[i]>0){ st=i; break; } } if(st==-1){ return 0; } ll s=0; for(ll i=st;i<N;i++){ ll t; if((i-st+1)%K==0){ s+=2LL*p[i]; t=s; }else{ t=s+2LL*p[i]; } ll ss=0; for(ll j=N-1;j>=i+1;j--){ ll tt; if((N-j)%K==0){ ss+=2LL*(L-p[j]); tt=ss; }else{ tt=ss+2LL*(L-p[j]); } res=min(res,t+tt+L*((j-i-1)/K+((j-i-1)%K>0))); } } return res; }
#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...