Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

dp怎么会wa

Posted by qxx at 2008-11-05 04:15:34 on Problem 3616
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator