제출 #707412

#제출 시각아이디문제언어결과실행 시간메모리
707412tht2005선물상자 (IOI15_boxes)C++17
50 / 100
2043 ms21712 KiB
#include <bits/stdc++.h> using namespace std; #define LL long long const LL INF = 1LL << 60; LL delivery(int N, int K, int L, int pos[]) { vector<LL> f(N + 1, INF); f[0] = 0; for(int i = 0; i < N; ++i) { for(int j = i; j < i + K && j < N; ++j) { LL cost = min(pos[j] + min(pos[j], L - pos[j]), L - pos[i] + min(pos[i], L - pos[i])); f[j + 1] = min(f[j + 1], f[i] + cost); } } return f[N]; } #ifdef tomoshibi int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, k, l, pos[100]; cin >> n >> k >> l; for(int i = 0; i < n; ++i) { cin >> pos[i]; } cout << delivery(n, k, l, pos); return 0; } #endif
#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...