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