题目链接http://poj.org/problem?id=2533
求最长上升子序列
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#define ll long long
#define PI 3.1415926535897932384626
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=2005;
int a[maxn],b[maxn];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
b[i]=1;
}
int length=1;
for(int i=1;i<n;i++){
for(int j=0;j<i;j++){
if(a[j]<a[i]){
b[i]=max(b[i],b[j]+1);
}
}
length=max(length,b[i]);
}
printf("%d\n",length);
}
return 0;
}