-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11053.java
More file actions
44 lines (37 loc) · 908 Bytes
/
11053.java
File metadata and controls
44 lines (37 loc) · 908 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
38
39
40
41
42
43
44
import java.util.Scanner;
public class Main {
static int arr[];
static int dp[];
public static int seq(int n){
if(dp[n]==-1){
dp[n]=1;
for(int i=0; i<n; i++){
if(arr[n]>arr[i]){
dp[n]=Math.max(dp[n],seq(i)+1);
}
}
}
return dp[n];
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
dp = new int[n];
for(int i=0; i<n; i++)
dp[i]=-1;
dp[0]=1;
for(int i=0; i<n; i++){
seq(i);
}
int max=0;
for(int i=0; i<n; i++){
if(max<dp[i])
max=dp[i];
}
System.out.println(max);
}
}