-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP158.java
More file actions
31 lines (29 loc) · 925 Bytes
/
P158.java
File metadata and controls
31 lines (29 loc) · 925 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
package condicionales;
import java.util.Scanner;
//accepted
public class P158 {
public static void main(String[] args) {
Scanner scN = new Scanner(System.in);
int alturaSalto, alturaSalto2=1;
int descenso, ascenso;
int casos = scN.nextInt();
for (int i = 0; i< casos; i++){
descenso=0;
ascenso=0;
int saltos = scN.nextInt();
for (int j=0;j<saltos; j++){
alturaSalto = scN.nextInt();
if (j==0){
alturaSalto2=alturaSalto;
}else {
if (alturaSalto2>alturaSalto){
descenso++;
} else if (alturaSalto2<alturaSalto){
ascenso++;
}alturaSalto2=alturaSalto;
}
}
System.out.println(ascenso + " " + descenso);
}
}
}