采药
70 3
71 100
69
1
1 2
样例输出 SampleOutput [复制数据]
3
1 #include<stdio.h> 2 int 3 max(int a,int b) 4 { 5 if (a>b) return(a); 6 else return(b); 7 } 8 9 int 10 main(void) 11 { 12 int t,m,t1,m1,i,j,a[2000]={0}; 13 scanf("%d%d\n",&t,&m); 14 for (i=1;i<=m;i++) 15 { 16 scanf("%d%d",&t1,&m1); 17 for (j=t;j>=t1;j--) 18 a[j]=max(a[j],a[j-t1]+m1); 19 20 } 21 printf("%d\n",a[t]); 22 return 0; 23 }
[TYVJ] P1005 采药,布布扣,bubuko.com
原文:http://www.cnblogs.com/sxiszero/p/3590676.html