-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcesor.java
More file actions
37 lines (32 loc) · 777 Bytes
/
Copy pathProcesor.java
File metadata and controls
37 lines (32 loc) · 777 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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class program {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
;
int[] arr = new int[n];
int[] len = new int[n];
for (int j = 0; j < n; j++) {
arr[j] = sc.nextInt();
}
List<Integer> list = new ArrayList<>();
int i;
for (int k = 0; k < n; k++) {
len[k] = 1;
for (i = 0; i < k; i++) {
if (arr[i] < arr[k] && ((arr[i] ^ arr[k]) & 1) == 1) {
len[k] = Integer.max(len[k], len[i] + 1);
}
}
}
for (int a = 0; a < n; a++) {
list.add(len[a]);
}
int max = Collections.max(list);
System.out.println(max);
}
}