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

造福后人

Posted by 834208094 at 2012-09-03 11:12:08 on Problem 1036
#include<iostream>
#include <string>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n, k, t, dp[300005] ;
struct Node{
    int t,values,with;
    bool operator < (const Node &no)const
    {
        return t < no.t;
    }
}ans[110];
int main()
{
	freopen("D:\\in.txt","r",stdin);
//	freopen("D:\\out.txt","w",stdout);
	while(scanf("%d %d %d", &n, &k, &t) != EOF)
	{
		memset(ans, 0, sizeof(ans));
		for(int i=1; i<=n; i++)    dp[i]= -1;
		dp[0] = 0;
		for(int i=1; i<=n; i++) scanf("%d", &ans[i].t);
		for(int i=1; i<=n; i++) scanf("%d", &ans[i].values);
		for(int i=1; i<=n; i++) scanf("%d", &ans[i].with);
		sort(ans+1, ans+n+1);		
		int ma = 0;//第一处WA,如果结果是0,ma=-1会WA 
		for(int i=1; i<=n; i++)
		{
			for(int j=0; j<i; j++)
			{
				if(abs(ans[j].t - ans[i].t) >= abs(ans[j].with - ans[i].with) && dp[j] != -1)//第二处WA是否j状态能取到 
				{
					dp[i] = max(dp[i], dp[j] + ans[i].values);
				}
			}
			if(dp[i] > ma) ma = dp[i];
		}
		cout<<ma<<endl;				
	}
	return 0;
}

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