B. Choosing Cubes

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Dmitry has n𝑛 cubes, numbered from left to right from 11 to n𝑛. The cube with index f𝑓 is his favorite.

Dmitry threw all the cubes on the table, and the i𝑖-th cube showed the value ai𝑎𝑖 (1≤ai≤1001≤𝑎𝑖≤100). After that, he arranged the cubes in non-increasing order of their values, from largest to smallest. If two cubes show the same value, they can go in any order.

After sorting, Dmitry removed the first k𝑘 cubes. Then he became interested in whether he removed his favorite cube (note that its position could have changed after sorting).

For example, if n=5𝑛=5, f=2𝑓=2, a=[4,3,3,2,3]𝑎=[4,3,3,2,3] (the favorite cube is highlighted in green), and k=2𝑘=2, the following could have happened:

  • After sorting a=[4,3,3,3,2]𝑎=[4,3,3,3,2], since the favorite cube ended up in the second position, it will be removed.
  • After sorting a=[4,3,3,3,2]𝑎=[4,3,3,3,2], since the favorite cube ended up in the third position, it will not be removed.

Input

The first line contains an integer t𝑡 (1≤t≤10001≤𝑡≤1000) — the number of test cases. Then follow the descriptions of the test cases.

The first line of each test case description contains three integers n𝑛, f𝑓, and k𝑘 (1≤f,k≤n≤1001≤𝑓,𝑘≤𝑛≤100) — the number of cubes, the index of Dmitry's favorite cube, and the number of removed cubes, respectively.

The second line of each test case description contains n𝑛 integers ai𝑎𝑖 (1≤ai≤1001≤𝑎𝑖≤100) — the values shown on the cubes.

Output

For each test case, output one line — "YES" if the cube will be removed in all cases, "NO" if it will not be removed in any case, "MAYBE" if it may be either removed or left.

You can output the answer in any case. For example, the strings "YES", "nO", "mAyBe" will be accepted as answers.

Example

input

Copy


  

12

5 2 2

4 3 3 2 3

5 5 3

4 2 1 3 5

5 5 2

5 2 4 1 3

5 5 5

1 2 5 4 3

5 5 4

3 1 2 4 5

5 5 5

4 3 2 1 5

6 5 3

1 2 3 1 2 3

10 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1

42

5 2 3

2 2 1 1 2

2 1 1

2 1

5 3 1

3 3 2 3 2

output

Copy

MAYBE
YES
NO
YES
YES
YES
MAYBE
MAYBE
YES
YES
YES
NO

6

解题说明:此题是一道数学题,判断是否移除特定数字,首先对数列排序,找出特定的数字所在的位置,然后用这个位置与移除的个数相比较。注意这里会存在多个相同的特定数字,此时要把位置全部记录下来。所有相同数字中如果位置靠后那肯定不会移除,如果只有一个数字靠后那可能会被移除,否则就肯定会被移除。

#include <stdio.h>
#include <stdlib.h>
int compare(const void* a, const void* b) 
{
	return (*(int*)b - *(int*)a);
}

int main() {
	int test, i, j;
	scanf("%d", &test);
	for (i = 0; i < test; i++)
	{
		int num, fav_index, rm;
		scanf("%d%d%d", &num, &fav_index, &rm);
		int arr[1002];
		for (j = 0; j < num; j++)
		{
			scanf("%d", &arr[j]);
		}
		int fav = arr[fav_index - 1];
		qsort(arr, num, sizeof(int), compare);
		int b[1002], k = 0;
		for (j = 0; j < num; j++) 
		{
			if (arr[j] == fav)
			{
				b[k] = j;
				k++;
			}
		}
		if (b[0] >= rm) 
		{
			printf("NO\n");
		}
		else if (b[k - 1] >= rm) 
		{
			printf("MAYBE\n");
		}
		else 
		{
			printf("YES\n");
		}
	}
	return 0;
}

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-13 02:08:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-13 02:08:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-13 02:08:02       87 阅读
  4. Python语言-面向对象

    2024-06-13 02:08:02       96 阅读

热门阅读

  1. 4.MongoDB sharding Cluster 分片集群

    2024-06-13 02:08:02       24 阅读
  2. mongo数据迁移方法

    2024-06-13 02:08:02       32 阅读
  3. 防护DDoS攻击出现的常见误区

    2024-06-13 02:08:02       26 阅读
  4. moocast(usaco2016年12月金组第1题)

    2024-06-13 02:08:02       30 阅读
  5. c#与汇川plc通信

    2024-06-13 02:08:02       30 阅读
  6. #07【面试问题整理】嵌入式软件工程师

    2024-06-13 02:08:02       30 阅读
  7. leetcode hot100 之 最长公共子序列

    2024-06-13 02:08:02       27 阅读
  8. SSRF-gopher 协议扩展利用:突破网络限制的利器

    2024-06-13 02:08:02       33 阅读
  9. Ant-Design-Vue 动态表头

    2024-06-13 02:08:02       27 阅读
  10. 深入理解ChatGPT工作原理

    2024-06-13 02:08:02       32 阅读
  11. minio

    minio

    2024-06-13 02:08:02      27 阅读