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

简短ac代码

Posted by yuziquan at 2017-05-18 16:02:09 on Problem 2533
//实质求严格上升子序列的长度,动态规划
#include<stdio.h>
#include<algorithm>
int a[1000], dp[1000];
int main(void)
{
	int n,ans=1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		dp[i] = 1;
		for (int j = 0; j < i; j++)
		{
			if (a[j] < a[i]) dp[i] =std:: max(dp[i], dp[j]+1);
		}
		ans = std::max(ans, dp[i]);
	}
	printf("%d\n", ans);
	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