A - Maximal Value
Editorial
/
/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ N の整数列 A=(A_1,A_2,\ldots,A_N) が与えられます。
A_i < A_{i+1} > A_{i+2} を満たす 1 以上 N-2 以下の整数 i の個数を求めてください。
制約
- 3\le N\le 100
- 1\le A_i\le 100
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
答えを出力せよ。
入力例 1
6 3 1 4 1 5 2
出力例 1
2
i=2,4 の 2 つが条件を満たします。したがって、2 を出力してください。
入力例 2
5 1 1 1 2 1
出力例 2
1
入力例 3
10 7 3 9 8 10 3 1 5 5 4
出力例 3
2
Score : 100 points
Problem Statement
You are given an integer sequence of length N: A=(A_1,A_2,\ldots,A_N).
Find the number of integers i between 1 and N-2 (inclusive) satisfying A_i < A_{i+1} > A_{i+2}.
Constraints
- 3\le N\le 100
- 1\le A_i\le 100
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_N
Output
Output the answer.
Sample Input 1
6 3 1 4 1 5 2
Sample Output 1
2
Two values i=2,4 satisfy the condition. Thus, output 2.
Sample Input 2
5 1 1 1 2 1
Sample Output 2
1
Sample Input 3
10 7 3 9 8 10 3 1 5 5 4
Sample Output 3
2