-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLISTest.java
More file actions
37 lines (31 loc) · 567 Bytes
/
LISTest.java
File metadata and controls
37 lines (31 loc) · 567 Bytes
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
package algorithm;
import java.util.*;
public class LISTest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] arr = new int[N];
int[] LIS = new int[N];
int max = 0;
for (int i = 0; i < N; i++) {
arr[i] = sc.nextInt();
LIS[i] = 1;
for (int j = 0; j < i; j++) {
if (arr[j] < arr[i] && LIS[i] < LIS[j]+1)
LIS[i] = LIS[j]+1;
}
if (max < LIS[i])
max = LIS[i];
}
System.out.println(max);
sc.close();
}
}
/*
6
3 2 6 4 5 1
==>3
10
8 2 4 3 6 11 7 10 14 5
==>6
*/