Problem: https://cses.fi/alon/task/1145
#include <iostream>
#include <vector>
using namespace std;
int n;
long long x;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
vector<long long> dp;
for (int i = 0; i < n; i++) {
cin >> x;
auto it = lower_bound(dp.begin(), dp.end(), x);
if (it == dp.end()) {
dp.push_back(x);
} else {
*it = x;
}
}
cout << dp.size() << '\n';
return 0;
}
Top comments (0)