标签:
题目链接:http://poj.org/problem?id=2533
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 35929 | Accepted: 15778 |
Description
Input
Output
Sample Input
7 1 7 3 5 9 4 8
Sample Output
4
求最长上升子序列
#include<stdio.h> #include<iostream> #include<math.h> #include<stdlib.h> #include<ctype.h> #include<algorithm> #include<vector> #include<string> #include<queue> #include<stack> #include<set> #include<map> using namespace std; int n,p[1010],dp[1010]; int main() { while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) scanf("%d",&p[i]); for (int i = 1; i <= n; i++) { dp[i] = 1; for (int j = 1; j < i; j++) { if (p[i] > p[j]) dp[i] = max(dp[i],dp[j] + 1); } } int ans = -1; for (int i = 1; i <= n; i++) ans = max(ans,dp[i]); printf("%d\n",ans); } return 0; }
poj-2533 Longest Ordered Subsequence 【最长上升子序列】
标签:
原文地址:http://blog.csdn.net/u014427196/article/details/44003711