A13392 | Orac and Medians
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Slime has a sequence of positive integers $a_1, a_2, \ldots, a_n$ .
In one operation Orac can choose an arbitrary subsegment $[l \ldots r]$ of this sequence and replace all values $a_l, a_{l + 1}, \ldots, a_r$ to the value of median of $\{a_l, a_{l + 1}, \ldots, a_r\}$ .
In this problem, for the integer multiset $s$ , the median of $s$ is equal to the $\lfloor \frac{|s|+1}{2}\rfloor$ -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 $a_1 = a_2 = \ldots = a_n = 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.
In one operation Orac can choose an arbitrary subsegment $[l \ldots r]$ of this sequence and replace all values $a_l, a_{l + 1}, \ldots, a_r$ to the value of median of $\{a_l, a_{l + 1}, \ldots, a_r\}$ .
In this problem, for the integer multiset $s$ , the median of $s$ is equal to the $\lfloor \frac{|s|+1}{2}\rfloor$ -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 $a_1 = a_2 = \ldots = a_n = 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.
输入格式
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\le n\le 100\,000)$ and $k\ (1\le k\le 10^9)$ , the second line contains $n$ positive integers $a_1,a_2,\dots,a_n\ (1\le a_i\le 10^9)$
The total sum of $n$ is at most $100\,000$ .
The first line of each query contains two integers $n\ (1\le n\le 100\,000)$ and $k\ (1\le k\le 10^9)$ , the second line contains $n$ positive integers $a_1,a_2,\dots,a_n\ (1\le a_i\le 10^9)$
The total sum of $n$ is at most $100\,000$ .
输出格式
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.
输入输出样例
输入 #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, $a_1=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]$ .
In the second query, $a_1=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]$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted