| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
简短ac代码//实质求严格上升子序列的长度,动态规划
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator