博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Himalayas (zoj 3809)
阅读量:6948 次
发布时间:2019-06-27

本文共 1643 字,大约阅读时间需要 5 分钟。

The Himalayas

Time Limit:
 2 Seconds     
 Memory Limit:
 65536 KB

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 <= i <= N - 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 <= 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

1 #include 
2 using namespace std; 3 int a[1000]; 4 int main() 5 { 6 int n; 7 int t; 8 cin>>t; 9 while(t--)10 {11 cin>>n;12 for(int i=0; i
>a[i];14 int sum=0;15 for(int i=1; i
a[i+1])18 sum++;19 }20 21 cout<
<

 

 

转载于:https://www.cnblogs.com/lengxia/p/4742613.html

你可能感兴趣的文章
Win10下安装Ubuntu16.04虚拟机并搭建TensorFlow1.3环境
查看>>
leetcode 108. Convert Sorted Array to Binary Search Tree
查看>>
【商城购物车】购物车逻辑
查看>>
PCIE协议解析 synopsys IP loopback 读书笔记(1)
查看>>
创建maven工程的时候卡死的解决办法
查看>>
Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
查看>>
微信小程序保存图片功能实现
查看>>
【Shiro】小读Shiro Filter(未完待续)
查看>>
Android环信即时通讯集成坑爹 注册报错208解决
查看>>
Flink及主流流框架spark,storm比较
查看>>
mysql按位的索引判断位的值
查看>>
一套简约漂亮的响应式博客园主题皮肤
查看>>
js获取时间戳
查看>>
Java数据结构和算法(四):栈
查看>>
为什么我的mac插入耳机耳机没有声音呢?
查看>>
ArcGIS js api 手动构建FeatureLayer
查看>>
Spark RDD持久化、广播变量和累加器
查看>>
Exception in thread "main" javax.validation.ValidationException: Unable to find a default provider
查看>>
Step by step SQL Server 2012的安装
查看>>
使用using 语句
查看>>