제출 #164611

#제출 시각아이디문제언어결과실행 시간메모리
164611handlename선물상자 (IOI15_boxes)C++14
100 / 100
623 ms255344 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { long long dp[N],dp2[N]; for (int i=0;i<N;i++){ if (i-K>=0) dp[i]=dp[i-K]+(p[i])*2; else dp[i]=p[i]*2; } for (int i=N-1;i>=0;i--){ if (i+K<N) dp2[i]=dp2[i+K]+(L-p[i])*2; else dp2[i]=(L-p[i])*2; } long long minans=1e18; for (int i=0;i<N-1;i++){ minans=min(minans,dp[i]+dp2[i+1]); } for (int i=K;i<N;i++){ minans=min(minans,dp[i-K]+dp2[i+1]+L); } minans=min(minans,dp[N-1]); minans=min(minans,dp2[0]); minans=min(minans,dp2[K]+L); minans=min(minans,dp[N-K]+L); return minans; }
#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...