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");
		}
	}
}

全部评论

相关推荐

Ryan188:我觉得你简历最核心的问题就是太大众化。 你要有一个认知就是,如果你是面试官,你是HR,其实他们每天都会收到非常多大量重复的像你这种简历。 就是说你的项目不是一个真实的上线的项目,可能是从网上学习而来的,或者是直接copy别人的项目,没有新意,没有展现出你自己对技术的思考,而且你的学历也不占优,自然而然就很难有人去选择你。 所以要做的实际上是差异化方向的工作,也就是“给我一个选择你的理由”,比如最近很火的ai,你可以写一个ai相关项目比如问答应用或者mcp编写或者agent搭建,需要你先花点时间学习,34天吧,展现你对这方面相较于其他人特有的思考; 或者写相关技术博客输出一些技术内容,有具体可以量化的成果等等去增加你的竞争力。 但以上这些都是后话,我去年在你这个时候也是没人理我,咱们双非学历也没实习,难找也正常,我当时整个3月份都没人鸟我,直到有个新招的岗位,很缺人很急,流程很快,所以我一下子进去了,所以运气方面也很重要,需要你一直坚持喝复盘,直到看到光明,加油兄弟
简历被挂麻了,求建议
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务