-
Notifications
You must be signed in to change notification settings - Fork 0
/
BOJ1365.cpp
47 lines (37 loc) · 838 Bytes
/
BOJ1365.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
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
const int INF = INT_MAX;
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
cin >> N;
vector<int> table;
int size = 0;
for(int i = 0; i < N; ++i) {
int input;
cin >> input;
int left = 0;
int right = size;
while(left < right) {
int mid = (left + right) / 2;
if(input > table[mid]) {
left = mid + 1;
} else {
right = mid;
}
}
if(left == size) {
table.push_back(input);
size++;
} else if(input < table[left]) {
table[left] = input;
}
}
cout << N - size << endl;
return 0;
}