제출 #868744

#제출 시각아이디문제언어결과실행 시간메모리
868744dpsaveslives선물상자 (IOI15_boxes)C++17
100 / 100
477 ms334644 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll delivery(int N, int K, int L, int positions[]){ vector<int> arr; arr.push_back(0); for(int i = 0;i<N;++i) arr.push_back(positions[i]); vector<ll> pref(N+2,0),suf(N+2,0); for(int i = 1;i<=N;++i){ pref[i] = arr[i]*2LL + (i > K ? pref[i-K] : 0); } for(int i = N;i>=1;--i){ suf[i] = (L-arr[i])*2LL + (i > N-K+1 ? 0 : suf[i+K]); } ll ans = suf[1]; for(int i = 0;i<=N;++i){ ans = min(ans,pref[i]+suf[i+1]); if(i+K <= N) ans = min(ans,pref[i]+L+suf[i+K+1]); else ans = min(ans,pref[i]+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...