Hdu2159 fate two-dimensional backpack-full backpack

Source: Internet
Author: User
/* 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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.