"Dynamic planning" for drug production

Source: Internet
Author: User

Your constancy, why shift up just before dawn sleep, the most useless, MO a day exposure 10th cold. "Dynamic planning" time limit for drug adoption : 1 Sec memory limit: up to MB

Title Description There are a number of different herbs in the cave, and it takes time for each plant to have its own value, and how to make the most of the herbs that are collected over time. Enter the first line there are two spaces separated by the integer T and M (1≤t,m≤100), T represents the total time to take medicine, M represents the number of herbs. The next M-line consists of two integers from 1 to 100 (including 1 and 100), each representing the time of picking a certain herb and the value of the herb. The output contains only an integer representing the maximum total value of the herbs that can be picked up within the prescribed time. Sample input
70 371 10069) 11 2
Sample output
3

Open space can not be given in accordance with the topic 1-100, to open a larger space ... Hang Hang Pit
#include <iostream>#include<cstring>using namespacestd;intt,m,f[1111],v[1111],w[1111];voidOnezeropack (intMintVintW//0-1 Backpack{     for(inti=m;i>=v;i--) F[i]=max (f[i],f[i-v]+w);}intMain () { while(cin>>t>>m) { for(intI=0; i<m;i++) Cin>>v[i]>>W[i]; Memset (F,0,sizeof(f));  for(intI=0; i<m;i++) Onezeropack (T,v[i],w[i]); cout<<f[t]<<Endl; }    return 0;}

"Dynamic planning" for drug production

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.