0%

poj2533 Longest Ordered Subsequence

题意

裸的最长上升子序列。。要求严格上升

题解

。。真没啥说的 这次用了二分查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=0x3f3f3f3f;
int dp[1040];
int main(){
int n;
scanf("%d",&n);
memset(dp,MAXN,sizeof(dp));
int ans=0;
for(int i=0;i<n;++i){
int tmp;
scanf("%d",&tmp);
int ide=lower_bound(dp,dp+n,tmp)-dp;
dp[ide]=tmp;
ans=max(ans,ide);
}
printf("%d\n",ans+1);
return 0;
}