#include #include #include using namespace std; struct kk { int a,b; }x[100010]; bool cmp(kk A,kk B) { return A.bx[n].b) flag=1; if (flag==0) { printf("-1\n"); continue; } now=1;long long ans=0; for (bb=0;bb<=10;bb++) { if (now>n) break; memset(f,70,sizeof(f)); //f[i][j]: first i,get >=j ,minimum cost //all bag f[0][0]=f[1][0]=0; for (i=1;i<=m;i++) { int t=i&1; for (j=1;j<=2000;j++) { f[t][j]=f[(i-1)&1][j]; if (p[i]<=bb) continue; if (p[i]-bb<=j) f[t][j]=min(f[t][j],f[t][j-p[i]+bb]+k[i]); } for (j=2000;j>=1;j--) if (f[t][j]