#include #include #include #include using namespace std; const int maxn = 1000+10; typedef long long LL; LL dp[maxn*2]; vector b[20]; int k[maxn]; int p[maxn]; const LL INF = 0x3f3f3f3f; int n,m; LL solve(int x){ for(int i=0;i=maxn*2){ continue; } dp[i+p[j]-x] = min(dp[i+p[j]-x],dp[i]+k[j]); } } for(int i=maxn*2-2;i>=0;i--){ dp[i] = min(dp[i],dp[i+1]); } LL ret=0; for(int i=0;i