Created
February 10, 2010 21:07
-
-
Save nhocki/300836 to your computer and use it in GitHub Desktop.
LIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <iostream> | |
#include <cmath> | |
#include <cstring> | |
#include <string> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <vector> | |
using namespace std; | |
#define D(x) cout <<#x" is "<< x << endl; | |
#define INF 2<<30-1 | |
int main(){ | |
int n; | |
while(scanf("%d", &n)==1){ | |
vector<long>S(n); | |
vector<long>M(n+1,INF); | |
for(int i=0;i<n;++i) scanf("%ld", &S[i]); | |
M[0]=0; | |
int _m = 0; | |
for(int i=0; i<S.size();++i){ | |
int d = upper_bound(M.begin(),M.begin()+n,S[i]) - M.begin(); | |
if(S[i]!=M[d-1]){ | |
M[d] = S[i]; | |
_m = max(_m,d); //_m >?=d; | |
//parent[S[i]] = M[d-1] | |
} | |
} | |
printf("%d\n",max(1,_m)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment