제출 #154118

#제출 시각아이디문제언어결과실행 시간메모리
154118mhy908선물상자 (IOI15_boxes)C++14
100 / 100
690 ms276060 KiB
#include "boxes.h" #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define llinf 8987654321987654321 #define inf 1987654321 using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; LL dp2[10000010], dp[10000010], arr[10000010], ans=llinf; LL delivery(int n, int k, int l, int p[]) { for(int i=0; i<n; i++) arr[i+1]=p[i]; for(int i=1; i<=n; i++) dp[i]=dp[max(0, i-k)]+2*arr[i]; for(int i=n; i>0; i--) dp2[i]=dp2[min(n+1, i+k)]+2*(l-arr[i]); for(int i=0; i<=n; i++)ans=min(ans, dp[i]+dp2[i+1]); for(int i=0; i<=n-k; i++)ans=min(ans, dp[i]+dp2[i+k+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...