/* Two-Dimensional backpack-full backpack cost 1 is the endurance value, cost 2 is the number of kill monsters (no input, all are 1) because every monster can be killed infinitely, therefore, it is a complete backpack. You can call the template */# include "bag2d. H "# include <iostream> using namespace STD; int main () {int n, m, K, S, I, J; while (CIN> N> m> K> S) {// n: required experience V1 = m; // M: Reserved endurance n = K; // K: Number of strange types v2 = s; // S: Maximum number of kill monsters memset (DP, 0, sizeof (DP); for (I = 0; I <K; I ++) CIN> V [I]> c1 [I]; for (I = 0; I <n; I ++) completepack2d (c1 [I], 1, V [I]); // you can find the minimum fee 1for (I = 0; I <= V1; I ++) {for (j = 0; j <= V2; j ++) {If (DP [I] [J]> = N) {cout <m-I <Endl; break ;}// if the J loop ends with break if (j <= V2) break ;} // If the I loop does not end with break if (I = V1 + 1) cout <-1 <Endl ;}return 0 ;}