#include #define ll long long using namespace std; const int maxn=100010,maxm=1010; ll a[maxn],b[maxn],k[maxm],p[maxm],dp[maxm][11]; long double aw(long double x1,long double y1,long double x2,long double y2) { return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); } long double cv(long double a,long double b,long double c) { return acos((b*b+c*c-a*a)/(2*b*c)); } int oneNumInBinary(ll n) { ll cnt=0; while(n) n=n&(n-1),cnt++; return cnt; } ll qpow(ll a,ll b) { ll ans=1; while(b) { if(b&1) ans=(ans*a)%999; a=a*a%999; b>>=1; } return ans; } inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9') {x=x*10+ch-'0'; ch=getchar();} return x*f; } inline string readstring() { string str; char s=getchar(); while(s==' '||s=='\n'||s=='\r') {s=getchar();} while(s!=' '&&s!='\n'&&s!='\r') {str+=s; s=getchar();} return str; } int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { ll up1=0,up2=0,hp=0; for(int i=0; i=up2) { printf("-1\n"); continue; } memset(dp,0,sizeof(dp)); for(int i=0; i<=10; i++)//0<=b[i]<=10 { for(int j=1; j<=hp; j++)//造成伤害值,0<=p[i]<=1000 { dp[j][i]=1e18; for(int u=0; u=j) dp[j][i]=min(dp[j][i],k[u]); else dp[j][i]=min(dp[j][i],dp[j-dmg][i]+k[u]); } } } ll ans=0; for(int i=0; i