Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- using namespace std;
- const int N = 239020;
- const int INF = 1000000007;
- int a[N], d[N];
- int main() {
- int n;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- d[0] = -INF;
- for (int i = 1; i <= n; ++i)
- d[i] = INF;
- int ans = 0;
- for (int i = 0; i < n; i++) {
- int j = int(upper_bound(d, d + n, a[i]) - d);
- if (d[j - 1] < a[i] && a[i] < d[j]) {
- d[j] = a[i];
- }
- }
- for (int i = 0; i < n; i++) {
- if (d[i] != INF) {
- ans = max(ans, i);
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement