| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
DP,贴代码,飘过~~#include <iostream>
#include<algorithm>
using namespace std;
bool dp[40001];
struct sti
{
int _h;
int _a;
int _c;
}v[401];
bool cmp(sti k,sti b) {return k._a <= b._a;}
int main()
{
int k,i,j,n;
while(scanf("%d",&n) != EOF)
{
for(i = 1;i <= n;i++)
scanf("%d%d%d",&v[i]._h,&v[i]._a,&v[i]._c);
sort(v + 1,v + n + 1,cmp);
memset(dp,0,sizeof(dp));
dp[0] = true;
int cmax = 0;
for(i = 1;i <= n;i++)
{
for(j = cmax;j >= 0;j--)
if(dp[j])
for(k = 1;k <= v[i]._c;k++)
{
int temp = j + v[i]._h * k;
if(temp > v[i]._a) break;
dp[temp] = true;
if(temp > cmax) cmax = temp;
}
}
printf("%d\n",cmax);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator