poj 3616 Milking Time

#include<iostream>        //dp
#include<algorithm>
using namespace std;
int dp[1005],n,m,r;
struct node
{
int s,e,eff;
bool operator<(const node& o)
{
return s<o.s||(s==o.s&&e<o.e);
}
}ans[
1005];
int main()
{
int i,j;
cin
>>n>>m>>r;
for(i=0;i<m;++i)
{
cin
>>ans[i].s>>ans[i].e>>ans[i].eff;
ans[i].e
+=r;
}
sort(ans,ans
+m);
for(i=0;i<m;++i)
{
dp[i]
=ans[i].eff;
for(j=0;j<i;++j)
if(ans[j].e<=ans[i].s)
dp[i]
=max(dp[i],dp[j]+ans[i].eff);
}
cout
<<*max_element(dp,dp+m)<<endl;
return 0;
}

  

posted on 2011-07-22 20:18  sysu_mjc  阅读(112)  评论(0编辑  收藏  举报

导航