标签:
3 7 40 3 5 23 8 2 52 6
48
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 const int maxn = 400010; 7 struct node{ 8 int h,c,a; 9 bool operator<(const node &t) const{ 10 return a < t.a; 11 } 12 }b[401]; 13 int dp[maxn],cnt[maxn]; 14 int main(){ 15 int n; 16 while(~scanf("%d",&n)){ 17 for(int i = 0; i < n; ++i) 18 scanf("%d %d %d",&b[i].h,&b[i].a,&b[i].c); 19 sort(b,b+n); 20 memset(dp,0,sizeof dp); 21 int ans = 0; 22 for(int i = 0; i < n; ++i){ 23 memset(cnt,0,sizeof cnt); 24 for(int j = b[i].h; j <= b[i].a; ++j){ 25 if(dp[j] < dp[j-b[i].h] + b[i].h && cnt[j-b[i].h] < b[i].c){ 26 dp[j] = dp[j-b[i].h] + b[i].h; 27 cnt[j] = cnt[j-b[i].h] + 1; 28 ans = max(ans,dp[j]); 29 } 30 } 31 } 32 printf("%d",ans); 33 } 34 return 0; 35 }
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/4442911.html