显示代码纯文本
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct point
{
int l,r,dis;
}a[1001];
int n,m,t,f[1001];
int cmp(const point &c,const point &d)
{
return c.r<d.r;
}
int main()
{
freopen("milkprod.in","r",stdin);
freopen("milkprod.out","w",stdout);
scanf("%d%d%d",&n,&m,&t);
for (int i=1; i<=m; ++i) scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].dis);
sort(a+1,a+m+1,cmp);
a[0].r=-99999999;
for (int i=1; i<=m; ++i)
for (int j=0; j<i; ++j)
if (a[j].r+t<=a[i].l)
f[i]=max(f[i-1],f[j]+a[i].dis);
printf("%d",f[m]);
}