HDU 1712 Group Backpack Starter

Source: Internet
Author: User

For each course, the learning time is different, the harvest is different, in a course spent two different time to learn is mutually exclusive, that is, they belong to the same group of items, directly do group backpack can.

Be aware that the order of the triple loops is immutable!

1#include <iostream>2#include <cstring>3#include <cstdio>4 using namespacestd;5 6 Const intINF =-99999999;7 Const intN =101;8 intA[n][n];9 intDp[n];Ten intN, M; One  A intMain () - { -      while(SCANF ("%d%d", &n, &m)! =EOF) the     { -         if(n = =0&& m = =0) Break; -          for(inti =1; I <= N; i++ ) -         { +              for(intj =1; J <= M; J + + ) -             { +scanf"%d", &a[i][j]); A             } at         } -Memset (DP,0,sizeof(DP)); -          for(inti =1; I <= N; i++ ) -         { -              for(intj = m; J >0; j-- ) -             { in                  for(intK =1; K <= J; k++ ) -                 { toDP[J] = max (Dp[j], dp[j-k] +a[i][k]); +                 } -             } the         } *printf"%d\n", Dp[m]); $     }Panax Notoginseng     return 0; -}

Note: There is no requirement to use enough m days, that is, the backpack can be dissatisfied.

HDU 1712 Group Backpack Starter

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.