제출 #591701

#제출 시각아이디문제언어결과실행 시간메모리
591701l_reho선물상자 (IOI15_boxes)C++14
10 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<long long> dpA(N+1, 0); vector<long long> dpB(N+1, 0); for(int i = 1; i <= N; i++){ if(i >= K){ dpA[i] = dpA[i-K]+p[i-1]*2; }else dpA[i] = dpA[0]+p[i-1]*2; } for(int i = N-1; i >= 0; i--){ if(i+K > N-1) dpB[i] = dpB[N] + (L-p[i])*2; else dpB[i] = dpB[i+K] + (L-p[i])*2; } long long ans = LLONG_MAX; for(int i = 1; i <= N; i++) ans = min(ans, dpA[i] + dpB[i]); for(int i = 1; i <= N; i++){ for(int j = 0; j < K; j++){ if(i+j > N-1) break; ans = min(ans, dpA[i] + dpB[i+j] + (long long)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...