[BOJ] 11053 가장 긴 증가하는 부분 수열

Time Lapse :None

11053.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>
using namespace std;

int N,x;
vector<int> v;
int main(void) {
v.push_back(-1);
cin>>N;
for(int i=0;i<N;i++) {
cin >> x;
if(v.back()<x)
{
v.push_back(x);
} else{
auto it = lower_bound(v.begin(),v.end(),x);
*it=x;
}
}
cout<<v.size()-1<<endl;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/23/PS/BOJ/11053/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.