标签:des style http java color os
1 8 2 2 100 4 4 100 2
400
<span style="font-size:18px;">#include<stdio.h> #include<iostream> #include<algorithm> #define M 1000005 using namespace std; int dp[M],v[M],p[M]; int max(int x,int y) { return (x>y?x:y); } int main () { int t,n,m,a,b,c,l; int i,j; cin>>t; while(t--) { l=0; cin>>n>>m; memset(v,0,sizeof(v)); memset(p,0,sizeof(p)); for(i=0;i<m;i++) { cin>>a>>b>>c; while(c--) { v[l]=a; p[l]=b; l++; } } memset(dp,0,sizeof(dp)); for(i=0;i<l;i++) for(j=n;j>=v[i];j--) dp[j]=max(dp[j],dp[j-v[i]]+p[i]); cout<<dp[n]<<endl; } return 0; }</span>
hdu 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活,布布扣,bubuko.com
hdu 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
标签:des style http java color os
原文地址:http://blog.csdn.net/fyxz1314/article/details/37968073