Description

CSU - 2062 Z‘s Array
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");
		}
	}
}

相关文章:

  • 2021-07-28
  • 2021-11-01
  • 2021-09-27
  • 2021-07-13
  • 2021-12-06
  • 2021-08-28
  • 2021-09-16
  • 2022-12-23
猜你喜欢
  • 2021-12-29
  • 2021-11-05
  • 2021-08-24
  • 2021-08-03
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案