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 juventus at 2008-03-08 17:49:18 on Problem 2533 and last updated at 2008-03-08 18:01:19
#include <iostream>
using namespace std;
void main()
{
	int sz[1001];
	int n,i;
	cin>>n;
	for (i=1;i<=n;i++) cin>>sz[i];
	sz[0]=INT_MAX;
	int maxLen[1001];
	maxLen[1]=1;
	int j;
	for (i=2;i<=n;i++)
	{
		j=i-1;
		while (sz[j]>=sz[i]) j--;
		if (j==0) maxLen[i]=1;
		else maxLen[i]=maxLen[j]+1;
	}
	int max=1;
	for (i=2;i<=n;i++)
	{
		if (max<maxLen[i])
			max=maxLen[i];
	}
	cout<<max<<endl;
}

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