| ||||||||||
| 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怎么会wa#include <stdio.h>
#include <algorithm>
using namespace std;
class event
{
public:
int e,s,num;
}t[1002];
int s[1000005];
int cmp(event a,event b)
{
return a.s<b.s;
}
int m,n;
int dp()
{
int maxx,i,j;
maxx=0;
j=1;
for(i=0;i<m;i++)
{
for(;t[i].s>j;j++)
{
if(maxx<s[j])maxx=s[j];
}
if(s[t[i].e]<maxx+t[i].num)s[t[i].e]=maxx+t[i].num;
}
for(;j<=n;j++)
{
if(maxx<s[j])maxx=s[j];
}
return maxx;
}
int main()
{
int r,i;
scanf("%d%d%d",&n,&m,&r);
for(i=0;i<m;i++)
{
scanf("%d%d%d",&t[i].s,&t[i].e,&t[i].num);
t[i].e+=r;
if(t[i].e>n)t[i].e=n;
}
sort(t,t+m,cmp);
printf("%d\n",dp());
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator