CSU - 2062 Z‘s Array
Description

Z likes to play with array. One day his teacher gave him an array of n elements, and ask Z whether the array is a "m-peek" array.
A "m-peek" array is an array which has exactly m peek.
a term a[i] is called a peek if and only if a[i]>a[i − 1] and a[i]>a[i + 1]
If the array has exactly m peeks, the array is called a "m-peek" array.
Input
The first line is the case number T
each case has two integer n, m where n denotes the number of elements in the array
then followed by n 32-bit signed integers in the array.
1 ≤ T ≤ 100
1 ≤ n ≤ 1000000
0 ≤ m ≤ n
Output
For each case,
print a single word "Yes" without quotation when the array is a "m-peek" array.
print "No" without quotation otherwise.
Sample Input
2
5 1
5 7 11 2 1
4 1
4 5 5 6
Sample Output
Yes
No
Hint
Source
Author
#include<stdio.h>
#define MAXN 1000010
int a[MAXN];
int main()
{
int t, n, m;
while (~scanf("%d", &t))
{
while (t--)
{
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
int num = 0;
for (int i = 1; i < n-1; i++)
{
if (a[i] >a[i - 1] && a[i] > a[i + 1])
{
num++;
}
}
if (num == m)
printf("Yes\n");
else
printf("No\n");
}
}
}
CSU - 2062 Z‘s Array的更多相关文章
- CSU - 2061 Z‘s Coffee
Description Z is crazy about coffee. One day he bought three cups of coffee. The first cup has a cap ...
- scala的多种集合的使用(5)之数组Array(ArrayBuffer)的操作
1.创建和更新数组的不同方式 1)定义一个数组的初始大小和类型,随后填充值. scala> val array = new Array[String](3) array: Array[Strin ...
- numpy.array 合并和分割
# 导包 import numpy as np numpy.array 的合并 .concatenate() 一维数组 x = np.array([1, 2, 3]) # array([1, 2, 3 ...
- java基础集合经典训练题
第一题:要求产生10个随机的字符串,每一个字符串互相不重复,每一个字符串中组成的字符(a-zA-Z0-9)也不相同,每个字符串长度为10; 分析:*1.看到这个题目,或许你脑海中会想到很多方法,比如判 ...
- BZOJ3160万径人踪灭
Description Input & Output & Sample Input & Sample Output HINT 题解: 题意即求不连续但间隔长度对称的回文串个数. ...
- 迷你MVVM框架 avalonjs 入门教程
新官网 请不要无视这里,这里都是链接,可以点的 OniUI组件库 学习教程 视频教程: 地址1 地址2 关于AvalonJs 开始的例子 扫描 视图模型 数据模型 绑定 作用域绑定(ms-contro ...
- LDA的Python实现源码
#-*- coding:utf-8 -*- import logging import logging.config import ConfigParser import numpy as np im ...
- Lua 与 Redis
Lua 与 Redis 标签: Java与NoSQL 从 2.6版本 起, Redis 开始支持 Lua 脚本 让开发者自己扩展 Redis - 案例-实现访问频率限制: 实现访问者 $ip 在一定的 ...
- 制作简单的2D物理引擎(一)——动力学基础
一切的基础 点 在二维平面中,点$P$就是坐标$(x,y)$,点集就是一系列坐标的集合$\{P_1,P_2,...,P_n\}$,不过这个集合是有序的(顺时针). 向量 加减运算 $$\vec{P}\ ...
随机推荐
- UC手机浏览器(U3内核)相关文档整理
Note:绝大多数API在IOS版下不支持,使用前请自行测试. UC官方的开发者中心:http://www.uc.cn/business/developer.shtml U3内核定制<meta& ...
- 截取汉字 mb_sbstr()
一.中文截取:mb_substr() mb_substr( $str, $start, $length, $encoding ) $str,需要截断的字符串 $start,截断开始处,起始处为0 $l ...
- Anaconda+django写出第一个web app(三)
前面我们已经建立了模型Tutorial,也已经可以用Navicat Premium打开数据看查看数据,接下来我们通过建立admin账户来上传数据. 在命令行执行如下命令来创建用户: python ma ...
- JS模块规范
ES6标准发布后,module成为标准,标准的使用是以export指令导出接口,以import引入模块,但是在我们一贯的node模块中,我们采用的是CommonJS规范,使用require引入模块,使 ...
- 2016.5.18——Excel Sheet Column Number
Excel Sheet Column Number 本题收获: 1.对于字符串中字母转为ASIIC码:string s ;res = s[i]-'A'; 这个res就是数字s[i]-'A'是对ASII ...
- js如何查看元素类型
<script type="text/javascript"> //定义变量temp var temp = Object.prototype.toString.appl ...
- 使用postman做接口测试(三)
三,接口用例的设计 个人感觉用例的设计才是重要的哈,网上查了一些资料总结了一下 1.业务流程测试 通过性验证: 1, 按照接口文档上的参数,正常传参,是否可以返回正确的结果 2, 是否满足前提条件,比 ...
- pyquery学习笔记
很早就听说了pyquery的强大.写了个简单的测试程序实验下. 思路是找个动态网页,先用PhantomJS加载,然后用PYQUERY解析. 1.随便找了个带表格的股票网页,里面有大量的股票数据,测试的 ...
- php修改文件上传大小限制
上传一个20M文件的时候php报如下错误,是php上传文件大小限制引起 POST Content-Length of 19248654 bytes exceeds the limit of 83886 ...
- Tomcat 上传war包后 会自动部署