
ZOJ Problem Set  3809
As an artist, Bob usually need to travel around the world. He made a lot of sketch of scenery on his journey. A famous spot he have visited recently is the Himalayas. The Himalayas is a mountain range in South Asia separating the plains of the Indian subcontinent from the QinghaiTibet Plateau. The Himalayas include over a hundred mountains exceeding 7,200 meters in elevation. One day, Bob came up with an strange idea. He wanted to know the number of mountain peaks in his paintings. As his best friend, he turned to you for help. You are given a list of N height sampling values H_{i}. You should determine how many peaks are there. For all i which satisfies 2 <= i <= N  1, H_{i} is defined as a peak if and only if H_{i1} < H_{i} > H_{i+1}. InputThere are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case: The first line contains one integer N (1 <= N <= 50). The next line contains N integers H_{i} (1 <= H_{i} <= 8844). It is guaranteed that any two adjacent height sampling values will be different. OutputFor each test case, output the number of peaks. Sample Input2 9 1 3 2 4 6 3 2 3 1 5 1 2 3 4 5 Sample Output3 0 Author: JIANG, Kai Source: The 2014 ACMICPC Asia Mudanjiang Regional First Round 