-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ12015.java
More file actions
44 lines (38 loc) · 1.17 KB
/
Copy pathJ12015.java
File metadata and controls
44 lines (38 loc) · 1.17 KB
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
package TIL;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class J12015 {
public static void main(String[] args) throws IOException{
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(buffer.readLine());
int[] num = new int[n];
String[] input = buffer.readLine().split(" ");
num[0] = Integer.parseInt(input[0]);
int size = 1;
for(int i = 1 ; i < n ; i++){
int l = Integer.parseInt(input[i]);
if(num[size-1] < l){
num[size++] = l;
}else{
int from = 0;
int to = size;
int mid = 0;
while(from < to){
mid = (from+to)/2;
if(num[mid] <l){
from = mid+1;
}else{
to = mid;
}
}
num[to] = l;
}
}
System.out.println(size);
}
}