-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12015.cpp
executable file
·61 lines (48 loc) · 967 Bytes
/
12015.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
// LIS
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000000001
using namespace std;
vector<int> input;
vector<int> ing_;
vector<int> final_;
int N = 0;
void PUSH(int a);
int main()
{
cin >> N;
for (int i = 0; i < N; i++)
{
int n = 0;
cin >> n;
input.push_back(n);
}
ing_.push_back(-(INF));
for (int i = 0; i < N; i++)
{
int n = 0;
n = input[i];
PUSH(n);
}
cout << ing_.size() - 1;
}
void PUSH(int a)
{
// 사이즈 체크
int prev_size = final_.size();
// ing_의 lowerbound를 찾아서 삽입한다.
vector<int>::iterator lowest = lower_bound(ing_.begin(), ing_.end(), a);
if (lowest == ing_.end())
{
// 제일 큰 값이 들어오는 경우이다.
ing_.push_back(a);
}
else
{
int index = 0;
index = lowest - ing_.begin();
ing_[index] = a;
}
}