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 fflyn258 at 2006-03-18 17:12:11 on Problem 2533
#include <iostream>
//#include <fstream>
using namespace std;
//ifstream fin("a.txt");
int solve(int );
int main()
{
	int n;
	cin>>n;
	cout<<solve(n)<<endl;
	return 1;
}
int solve(int n)
{
	int i,j,max;
	int num[1010];
	int ans[1010];
	for(i=0;i<n;i++){
		cin>>num[i];
		ans[i]=1;
	}
	for(i=n-2;i>=0;i--){
		max=1;
		for(j=i+1;j<=n-1;j++)
			if(num[i]<num[j]&&max<ans[j]+1)
				max=ans[j]+1;
		ans[i]=max;
	}
	return ans[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