-
时间:2016-03-28 17:27:03 星期一
-
题目编号:[2016-03-28][POJ][3616][Milking Time]
#include <algorithm>
#include <cstdio>
using namespace std;
const int maxm = 1000 + 10;
struct Roo{
int l,r,v;
bool operator < (const Roo & a)const{
return l < a.l;
}
}a[maxm];
int dp[maxm];
int main(){
int n,m,r;
scanf("%d%d%d",&n,&m,&r);
for(int i = 1;i <= m ; ++i){
scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].v);
}
sort(a+1,a+1+m);
int ans = 0;
for(int i = 1;i <= m;++i){
dp[i] = a[i].v;
for(int j = 1;j < i ; ++j){
if(a[j].r + r <= a[i].l){
dp[i] = max(dp[i],dp[j] + a[i].v);
}
}
ans = max(dp[i],ans);
}
printf("%d\n",ans);
return 0;
}
时间: 2024-10-07 15:10:02