Skip to content

Instantly share code, notes, and snippets.

@takageymt
Created March 9, 2017 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takageymt/d45df838efef5a6289226b4ef46c48ab to your computer and use it in GitHub Desktop.
Save takageymt/d45df838efef5a6289226b4ef46c48ab to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
const int inf = 1LL << 55;
const int mod = 1e9 + 7;
signed main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(12);
int n, c[30000];
cin >> n;
rep(i, n) cin >> c[i];
int dp[30030];
fill(dp, dp + n, inf);
rep(i, n) {
*lower_bound(dp, dp + n, c[i]) = c[i];
}
cout << n - (lower_bound(dp, dp + n, inf) - dp) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment