#include using namespace std; typedef long long LL; const int maxn=100009; const int maxm=1009; const int maxh=1500; const LL INF=1000000000000000LL; int a[maxn],b[maxn]; int k[maxm],p[maxm]; int cnt[11]; LL dp[maxh][11]; int n,m; int main() { while(scanf("%d%d",&n,&m)!=-1) { for(int i=0;i