#include using namespace std; __int64 dp[1005][11],num[1005][11],sum; int sk[1005]; struct node { int k,p; }q[1005]; int main() { int n,m,i,j,l,a,b,len; while(~scanf("%d%d",&n,&m)){ memset(dp,0,sizeof(dp)); memset(num,0,sizeof(num)); memset(sk,0,sizeof(sk)); int min_b=15,max_a=0,max_b=0,max_p=0; for(i=0;iq[j].k) cnt=q[j].k; continue; } if(cnt==-1||cnt>dp[i-op][l]+q[j].k) cnt=dp[i-op][l]+q[j].k; } dp[i][l]=cnt; } } sum=0; for(i=1;i<=max_a;i++) for(j=0;j<=10;j++) sum+=dp[i][j]*num[i][j]; printf("%I64d\n",sum); } return 0; }