http://poj.org/problem?id=2533
在经典不过的DP题目了。。。。
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define mem0(a) memset(a,0,sizeof(a)) typedef long long LL;
const double eps = 1e-;
const int MAXN = ;
const int MAXM = ; int DP[], a[], N; int BinarySearch(int low, int high, int val)
{
while(low < high)
{
int mid = (low + high) >> ;
if(DP[mid] < val) low = mid +;
else high = mid;
}
return low;
} int main()
{
while(~scanf("%d", &N))
{
for(int i=;i<=N;i++)
{
scanf("%d", &a[i]);
}
DP[] = a[];
int len = ;
for(int i=;i<=N;i++)
{
int id = BinarySearch(, len+, a[i]);
DP[id] = a[i];
if(id > len) ++len;
}
printf("%d\n", len);
}
return ;
}