38 lines
867 B
Java
38 lines
867 B
Java
import java.util.*;
|
|
|
|
public class _12015 {
|
|
public static void main(String args[]) {
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
int N = sc.nextInt();
|
|
int[] A = new int[N];
|
|
for(int i=0; i<N; i++) A[i] = sc.nextInt();
|
|
|
|
sc.close();
|
|
|
|
int[] LIS = new int[N];
|
|
int len = 0;
|
|
LIS[len++] = A[0];
|
|
|
|
for(int i=1; i<N; i++) {
|
|
int num = A[i];
|
|
|
|
if(LIS[len-1] < num) LIS[len++] = num;
|
|
else {
|
|
int left = 0, right = len-1;
|
|
int mid = (left + right) / 2;
|
|
while(left < right) {
|
|
if(LIS[mid] < num) left = mid + 1;
|
|
else right = mid;
|
|
|
|
mid = (left + right) / 2;
|
|
}
|
|
|
|
LIS[mid] = num;
|
|
}
|
|
}
|
|
|
|
System.out.println(len);
|
|
}
|
|
}
|