제출 #747217

#제출 시각아이디문제언어결과실행 시간메모리
747217Abrar_Al_Samit선물상자 (IOI15_boxes)C++17
50 / 100
49 ms21728 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; const int nax = 1e3 + 3; const long long INF = 1e18; long long dp[nax][nax]; int n, k, L; int a[nax]; //a[0] = a[n+1] = 0 long long solve(int i, int j) { if(i>n) return 0; long long &ret = dp[i][j]; if(ret!=-1) return ret; ret = INF; if(j!=k) ret = solve(i+1, k-1) + min(a[i], L-a[i]) + min(a[i+1], L-a[i+1]); if(a[i+1]==0 || j>0) { ret = min(ret, solve(i+1, j-1) + min(abs(a[i+1]-a[i]), L-abs(a[i+1]-a[i]))); } return ret; } long long delivery(int N, int K, int l, int p[]) { n = N, k = K, L = l; memset(dp, -1, sizeof dp); for(int i=1; i<=n; ++i) { a[i] = p[i-1]; } return solve(0, k); }
#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...