1129_TheHimalayas

2022-5-16 18:16| 发布者: Hocassian| 查看: 61| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-2-89503627625500-Problem List-采集的数据-后羿采集器.html

Pro.ID

1129

Title

The Himalayas

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=1129

AC

280

Submit

503

Ratio

55.67%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    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 Qinghai-Tibet 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 Hi. You should determine how many peaks are there. For all i which satisfies 2 ≤ iN - 1, Hi is defined as a peak if and only if Hi-1 < Hi > Hi+1.

    输入

    There 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 Hi (1 ≤ Hi ≤ 8848). It is guaranteed that any two adjacent height sampling values will be different.

    输出

    Description

    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 Qinghai-Tibet 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 Hi. You should determine how many peaks are there. For all i which satisfies 2 ≤ iN - 1, Hi is defined as a peak if and only if Hi-1 < Hi > Hi+1.

    Input

    There 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 Hi (1 ≤ Hi ≤ 8848). It is guaranteed that any two adjacent height sampling values will be different.

    Output

    For each test case, output the number of peaks.

    Sample Input

    2
    9
    1 3 2 4 6 3 2 3 1
    5
    1 2 3 4 5

    Sample Output

    3
    0

    样例输入

    2
    9
    1 3 2 4 6 3 2 3 1
    5
    1 2 3 4 5

    样例输出

    3
    0

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部