CF1349B.Orac and Medians
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Slime has a sequence of positive integers a1,a2,…,an.
In one operation Orac can choose an arbitrary subsegment [l…r] of this sequence and replace all values al,al+1,…,ar to the value of median of al,al+1,…,ar.
In this problem, for the integer multiset s, the median of s is equal to the ⌊2∣s∣+1⌋-th smallest number in it. For example, the median of 1,4,4,6,5 is 4, and the median of 1,7,5,8 is 5.
Slime wants Orac to make a1=a2=…=an=k using these operations.
Orac thinks that it is impossible, and he does not want to waste his time, so he decided to ask you if it is possible to satisfy the Slime's requirement, he may ask you these questions several times.
史莱姆有一个正整数序列 a1,a2,…,an。
在一次操作中,奥拉克可以选择该序列的任意一个子区间 [l…r],并将所有值 al,al+1,…,ar 替换为集合 {al,al+1,…,ar} 的中位数。
本题中,对于整数多重集 s,其中位数定义为其中第 ⌊2∣s∣+1⌋ 小的数。例如,{1,4,4,6,5} 的中位数是 4,而 {1,7,5,8} 的中位数是 5。
史莱姆希望奥拉克通过这些操作使得 a1=a2=…=an=k。
奥拉克认为这是不可能的,他不想浪费时间,因此决定向你询问:是否可能满足史莱姆的要求?他可能会多次向你提出此类问题。
输入格式
The first line of the input is a single integer t: the number of queries.
The first line of each query contains two integers n (1≤n≤100000) and k (1≤k≤109), the second line contains n positive integers a1,a2,…,an (1≤ai≤109)
The total sum of n is at most 100000.
输入的第一行是一个整数 t:查询次数。
每个查询的第一行包含两个整数 n (1≤n≤100000) 和 k (1≤k≤109),第二行包含 n 个正整数 a1,a2,…,an (1≤ai≤109)。
所有查询中 n 的总和不超过 100000。
输出格式
The output should contain t lines. The i-th line should be equal to 'yes' if it is possible to make all integers k in some number of operations or 'no', otherwise. You can print each letter in lowercase or uppercase.
输出应包含 t 行。第 i 行应为 yes(如果可以通过若干次操作使所有整数变为 k),否则为 no。每个字母可使用小写或大写形式输出。
输入输出样例
输入#1
5 5 3 1 5 2 6 1 1 6 6 3 2 1 2 3 4 3 3 1 2 3 10 3 1 2 3 4 5 6 7 8 9 10
输出#1
no yes yes no yes
说明/提示
In the first query, Orac can't turn all elements into 3.
In the second query, a1=6 is already satisfied.
In the third query, Orac can select the complete array and turn all elements into 2.
In the fourth query, Orac can't turn all elements into 3.
In the fifth query, Orac can select [1,6] at first and then select [2,10].
在第一次查询中,Orac 无法将所有元素变为 3。
在第二次查询中,a1=6 已经满足条件。
在第三次查询中,Orac 可以选择整个数组,并将所有元素变为 2。
在第四次查询中,Orac 无法将所有元素变为 3。
在第五次查询中,Orac 可以先选择 [1,6],然后选择 [2,10]。
输入解题思路,AI测评打分。不知道怎么写?