Skip to content

Commit

Permalink
Add solution
Browse files Browse the repository at this point in the history
  • Loading branch information
RikuPutkinen committed Sep 18, 2023
1 parent 6431d47 commit 19c8fd3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dynamic-programming/increasing-subsequence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Increasing Subsequence

Problem page: <https://cses.fi/problemset/task/1145/>
25 changes: 25 additions & 0 deletions dynamic-programming/increasing-subsequence/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
int n{}, x{};
cin >> n;
vector<int> v;

for (int i = 0; i < n; i++){
cin >> x;
auto it = lower_bound(v.begin(), v.end(), x);
if (it == v.end()){
v.push_back(x);
}else{
*it = x;
}
}

cout << v.size() << "\n";

return 0;
}

0 comments on commit 19c8fd3

Please sign in to comment.