TopCoder

ItzYouLingTW
資研社的大家好ouo/

User's AC Ratio

100.0% (4/4)

Submission's AC Ratio

83.3% (5/6)

Tags

Description

給一個長度為 $n$ 的序列 $A$,問總共有幾個山坡?
山坡代表在序列中選一個 $i$ 並且 $1 < i < n$,滿足 $A_{i - 1} < A_i > A_{i + 1}$。


對於所有測試資料:
$1 \le n,\ A_i \le 100$

Input Format

共輸入兩行,
第一行輸入一個數字 $n$,
第二行輸入 $n$ 個數字,第 $i$ 個數字為 $A_i$。

Output Format

輸出一個數字代表答案。

Sample Input 1

3
1 2 1

Sample Output 1

1

Sample Input 2

4
1 2 2 1

Sample Output 2

0

Sample Input 3

5
1 3 2 4 1

Sample Output 3

2

Hints

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~2 範例測試資料 0
2 0, 3~12 $n = 3$ 25
3 0~22 無額外限制 75

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1 2 3
1 1000 65536 65536 1 3
2 1000 65536 65536 1 3
3 1000 65536 65536 2 3
4 1000 65536 65536 2 3
5 1000 65536 65536 2 3
6 1000 65536 65536 2 3
7 1000 65536 65536 2 3
8 1000 65536 65536 2 3
9 1000 65536 65536 2 3
10 1000 65536 65536 2 3
11 1000 65536 65536 2 3
12 1000 65536 65536 2 3
13 1000 65536 65536 3
14 1000 65536 65536 3
15 1000 65536 65536 3
16 1000 65536 65536 3
17 1000 65536 65536 3
18 1000 65536 65536 3
19 1000 65536 65536 3
20 1000 65536 65536 3
21 1000 65536 65536 3
22 1000 65536 65536 3