-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincreasing_subsequence.cpp
More file actions
49 lines (40 loc) · 876 Bytes
/
Copy pathincreasing_subsequence.cpp
File metadata and controls
49 lines (40 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
template <typename T>
using indexed_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<int> b;
for (int i = 0; i < n; ++i) {
auto it = lower_bound(all(b), a[i]);
if (it == b.end()) {
b.push_back(a[i]);
} else {
*it = a[i];
}
}
cout << b.size() << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc = 1;
// cin >> tc;
while (tc--) {
solve();
}
}