#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long a[100005],b[100005]; long long k[1005],p[1005]; long long dp[1005][15]; int main (){ long long n,m; while (scanf ("%lld%lld",&n,&m)!=EOF){ long long maxb=0,maxa=0; for (int i=0;i=maxp){ printf ("-1\n"); continue; } memset(dp,0x3f3f3f3f,sizeof(dp)); for (int i=0;i<=10;i++) dp[0][i]=0; for (int i=0;i<=10;i++){// 护甲 for (int j=1;j<=maxa;j++){// 血量 for (int l=0;l=j){ dp[j][i]=min(dp[j][i],k[l]); } else if (p[l]-i>0){ dp[j][i]=min(dp[j][i],dp[j-(p[l]-i)][i]+k[l]); } } } } long long ans=0; for (int i=0;i