-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy path[08]_4.java
More file actions
35 lines (28 loc) · 741 Bytes
/
[08]_4.java
File metadata and controls
35 lines (28 loc) · 741 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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static ArrayList<Integer> data = new ArrayList<Integer>();
public static int ascending() {
int now = data.get(0);
int result = 1;
for (int i = 1; i < data.size(); i++) {
if (now < data.get(i)) {
result += 1;
now = data.get(i);
}
}
return result;
}
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
for (int i = 0; i < n; i++) {
int x = Integer.parseInt(sc.nextLine());
data.add(x);
}
System.out.println(ascending());
Collections.reverse(data);
System.out.println(ascending());
}
}