The Himalayas
来源:互联网 发布:一战各国伤亡知乎 编辑:程序博客网 时间:2024/06/05 09:22
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 ofN height sampling values Hi. You should determine how many peaks are there. For alli which satisfies 2 <= i <= N - 1, Hi is defined as a peak if and only ifHi-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 containsN integers Hi (1 <= Hi <= 8844). 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
291 3 2 4 6 3 2 3 151 2 3 4 5
Sample Output
30
水题,求 Hi-1 <Hi > Hi+1.的个数。
*/
#include<cstdio>int main(){int T,n,i,a[9000],t;scanf("%d",&T);while(T--{scanf("%d",&n);for(i=0; i<n; i++){scanf("%d",&a[i]);}for(i=1,t=0; i<n-1;){if(a[i]>a[i-1]&&a[i]>a[i+1]){t++;i+=2;}else{i++;}}printf("%d\n",t);}}
- The Himalayas
- ZOJ-#3809 The Himalayas
- ZOJ 3809 The Himalayas
- zoj 3809 The Himalayas(水题)
- ZOJ - 3809 The Himalayas 暴力
- The Himalayas(ZOJ)(牡丹江赛区)
- ZOJ3943-Himalayas
- The Himalayas --The 2014 ACM-ICPC Asia Mudanjiang Regional First Round - A
- zoj 3809 The Himalayas 水题 The 2014 ACM-ICPC Asia Mudanjiang Regional First Round
- [ACM] zoj 3809 The Himalayas (2014 ACMICPC Regional 牡丹江站网络赛 A题)
- ZOJ 3809 The Himalayas (2014 ACM/ICPC 牡丹江站 网络预选赛 A 题)
- ZOJ 3818 The Himalayas (2014 ACM/ICPC 牡丹江站 网络预选赛 J 题)
- ZOJ 3943Himalayas
- The hell--The hope
- the Denser the Better ?
- the CComSingleThreadModel & the CComMultiThreadModel
- The more, The Better
- the+比较级,the+比较级
- poj3658 模拟
- 算法导论-优先级队列-C语言
- 环境变量和export的命令--shell进程的变量可见域问题
- 已将GitHub scrapy-redis库升级,使其兼容最新版本Scrapy
- 如何提高Axure设计的效率 提高Axure设计效率的10条建议
- The Himalayas
- Linux页框管理
- Enterprise Architect里面能否直接全屏查看图
- 解决Servlet中get或post中文乱码问题
- KNN算法的CUDA实现
- 理解Context
- 操作系统之处理器管理与存储器管理
- GreenDao 学习笔记 3
- fdsfsdfsdfsdf