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 win1611 at 2010-03-16 18:13:20 on Problem 2533
#include<iostream>
using namespace std;

int cmp(const void *a,const void *b)
{
	return (*(int *)a-*(int *)b);
}
int L[1001][1001];
int main()
{
	int i,j;
	int N,aa[1001],bb[1001];

	
	while(scanf("%d",&N)!=EOF){

		memset(aa,0,sizeof(aa));
		memset(bb,0,sizeof(bb));
		memset(L,0,sizeof(L));

		for(i = 0;i < N;i ++){
			scanf("%d",&aa[i]);
			bb[i] = aa[i];
		}
		qsort(bb,N,sizeof(bb[0]),cmp);

		for(i = 0;i <= N;i++){
			L[i][0] = 0;
			L[0][i] = 0;
		}
		for(i = 1;i <= N;i ++)
			for(j = 1;j <=N;j ++){
				if(aa[i]==bb[j]){
					L[i][j] = L[i-1][j-1] + 1;
				}
				else{
					L[i][j] = (L[i][j-1] > L[i-1][j] ? L[i][j-1] : L[i-1][j]);
				}
			}
			printf("%d\n",L[N][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