-
Notifications
You must be signed in to change notification settings - Fork 0
/
p376.java
33 lines (28 loc) · 972 Bytes
/
p376.java
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
package com.caiomed03.aceptaelreto;
import java.util.Scanner;
public class p376 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int nRutas = sc.nextInt();
while (!(nRutas == 0)) {
int[] picos = new int[nRutas];
int cont=0;
for(int i=0; i<nRutas; i++){
picos[i] = sc.nextInt();
}
for(int i=0; i<nRutas; i++){
if(i==0){
if(picos[0]>picos[1] && picos[0]>picos[picos.length-1]) cont++;
}
else if(i==nRutas-1){
if(picos[picos.length-1]>picos[i-1] && picos[picos.length-1]>picos[0]) cont++;
}
else{
if (picos[i]>picos[i-1] && picos[i]>picos[i+1]) cont++;
}
}
System.out.println(cont);
nRutas =sc.nextInt();
}
}
}