Submission #16526

#TimeUsernameProblemLanguageResultExecution timeMemory
16526CodingBugBoxes with souvenirs (IOI15_boxes)C++98
100 / 100
735 ms197648 KiB
#include "boxes.h" #include <algorithm> #define M 10000000 using namespace std; long long d[2][M+1]; long long delivery(int N, int K, int L, int p[]) { sort(p,p+N); for(int i=0;i<N;i++) d[0][i]=(i>=K ? d[0][i-K] : 0ll)+min(p[i]*2,L); for(int i=N-1;i>=0;i--) d[1][i]=(i+K<N ? d[1][i+K] : 0ll)+min((L-p[i])*2,L); long long mn=min(d[0][N-1],d[1][0]); for(int i=1;i<N;i++) mn=min(mn,d[0][i-1]+d[1][i]); return mn; }
#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...