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

为什么不停的RE啊

Posted by gwy at 2011-07-28 16:47:25 on Problem 1609
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

typedef struct{
	int le, mi;
}blo;

blo b[10005];
int f[10005];

int cmp(const blo &a, const blo &c){
	if (a.le>c.le) return 0;
	else 
	  if (a.le==c.le){
	      if (a.mi>c.mi) return 0;
	      else return 1;
	  }
	  else return 1;
}

main(){
	int n, i, j, k, max;
	while(scanf("%d",&n),n!=0){
		memset(f,-1,sizeof(f));
		f[0]=0;
		b[0].le=0; b[0].mi=0;
		for (i=1;i<=n;++i) scanf("%d%d",&b[i].le,&b[i].mi);
		sort(b+1,b+n+1,cmp);
		for (i=1;i<=n;++i)
		  for (j=0;j<i;++j)
		    if (b[i].le>=b[j].le && b[i].mi>=b[j].mi && f[i]<f[j]+1)
		    f[i]=f[j]+1;
		max=0;
		for (i=1;i<=n;++i)
		  if (f[i]>max) max=f[i];
		printf("%d\n",max);
	}
	printf("*\n");
	//system("pause");
	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