标签:des style color java os strong io 数据
1 10 5 1 5 100 3 10 10 5 10 100 1 4 2 6 12 266
102
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
struct node
{
int s,e,c;
}a[10005];
bool cmp(node a,node b) // 对 结束时间 排序
{
return (a.e<b.e);
}
int max(int x,int y)
{
return (x>y?x:y);
}
int main ()
{
int T,n,m,i,j;
int dp[10005];
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&m,&n);
for(i=0;i<n;i++)
scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].c);
sort(a,a+n,cmp);
memset(dp,0,sizeof(dp));
// 背包问题
for(i=0;i<n;i++) // 工作数 为背包容量
{
for(j=m;j>=a[i].e;j--)
{
dp[j]=max(dp[j],dp[a[i].s-1]+a[i].c); // 做与不做
}
}
printf("%d\n",dp[m]);
}
return 0;
}
hdu 4502 吉哥系列故事——临时工计划,布布扣,bubuko.com
标签:des style color java os strong io 数据
原文地址:http://blog.csdn.net/fyxz1314/article/details/38350435