-
Notifications
You must be signed in to change notification settings - Fork 0
/
12015.cpp
44 lines (41 loc) · 813 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
#include<iostream>
#include<vector>
using namespace std;
vector<int>v;
vector<int>answer;
int n;
int binaryFunction(int num){
int s = 0, e = answer.size()-1;
int mid;
while(s < e){
mid = (s + e)/2;
if((answer[mid] >= num)){
e = mid;
}
else {
s = mid+1;
}
}
return s;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
int tmp;
for(int i = 0 ; i < n; i++){
cin >> tmp;
v.push_back(tmp);
}
answer.push_back(v[0]);
for(int i = 1; i < n; i++){
if(v[i] > answer.back()){
answer.push_back(v[i]);
}
else if(v[i] < answer.back()){
answer[binaryFunction(v[i])] = v[i];
}
}
cout << answer.size();
}