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

数据都过,为啥就是wa

Posted by congcongbebe at 2010-04-13 21:25:47 on Problem 1609
#include<stdio.h>
#include<stdlib.h>
struct game
{
	int l;
	int m;
}a[10001];
int cmp(const void *c,const void *d)
{
	return ((struct game *)c)->l - ((struct game *)d)->l; 
}
int dp[10001];
int main()
{
	int n,i,j,max,tmax;
	while(scanf("%d",&n) && n)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&a[i].l,&a[i].m);
		}
		qsort(a,n,sizeof(a[0]),cmp);

		dp[0]=1;
		for(i=0;i<n;i++)
			dp[i]=1;
		for(i=1;i<n;i++)
		{
			max=0;
			for(j=0;j<i;j++)
			{
				if(a[i].m>=a[j].m)
				{
					if(max<dp[j])
					{
						max=dp[j];
					}
				}
			}
			dp[i]=max+1;
		}
		tmax=0;
		for(i=0;i<n;i++)
		{
			if(tmax<dp[i])
				tmax=dp[i];
		}
		printf("%d\n",tmax);
	}
	printf("*\n");
	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