File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ ```java
2+ import java.io.*;
3+ import java.util.*;
4+
5+ public class Main {
6+ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+ static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+ static StringTokenizer st;
9+ static int N;
10+ static List<Integer> LIS;
11+
12+ public static void main(String[] args) throws IOException {
13+ N = Integer.parseInt(br.readLine());
14+ LIS = new ArrayList<>();
15+ st = new StringTokenizer(br.readLine());
16+ for (int i = 0; i < N; i++) {
17+ int cur = Integer.parseInt(st.nextToken());
18+ if(LIS.isEmpty() || LIS.get(LIS.size()-1) < cur){
19+ LIS.add(cur);
20+ }else{
21+ LIS.set(binarySearch(cur),cur);
22+ }
23+ }
24+ bw.write(LIS.size() + "\n");
25+ bw.close();
26+ }
27+ public static int binarySearch(int target) {
28+ int left = 0; int right = LIS.size() - 1;
29+ while(left < right){
30+ int mid = (left + right) / 2;
31+ if(LIS.get(mid) < target){
32+ left = mid + 1;
33+ }else{
34+ right = mid;
35+ }
36+ }
37+ return left;
38+ }
39+ }
40+ ```
You can’t perform that action at this time.
0 commit comments