Skip to content

Instantly share code, notes, and snippets.

@KPCCoiL
Created June 24, 2014 08:33
Show Gist options
  • Save KPCCoiL/0bfe31439ac75497dd46 to your computer and use it in GitHub Desktop.
Save KPCCoiL/0bfe31439ac75497dd46 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> vec(n);
for (int& i : vec) cin>>i;
constexpr int INF = 1e8;
const int len = vec.size();
vector<int> dp(len,INF);
for (int i = 0; i < len; i++)
*lower_bound(dp.begin(),dp.end(),vec[i]) = vec[i];
cout << distance(dp.begin(),lower_bound(dp.begin(),dp.end(),INF)) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment