欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1746A.Maxmina
Maxmina
You have an array of size consisting only of zeroes and ones and an integer . In one operation you can do one of the following:
- Select consecutive elements of and replace them with their minimum (that is, let $a := [a_{1}, a_{2}, \ldots, a_{i-1}, \min(a_{i}, a_{i+1}), a_{i+2}, \ldots, a_{n}]$ for some ). This operation decreases the size of by .
- Select consecutive elements of and replace them with their maximum (that is, let $a := [a_{1}, a_{2}, \ldots, a_{i-1}, \max(a_{i}, a_{i+1}, \ldots, a_{i+k-1}), a_{i+k}, \ldots, a_{n}]$ for some ). This operation decreases the size of by .
Determine if it's possible to turn into after several (possibly zero) operations.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and (), the size of array and the length of segments that you can perform second type operation on.
The second line contains integers ( is or ), elements of array .
Output
For each test case, if it is possible to turn into , print "YES", otherwise print "NO".
Note
In the first test case, you can perform the second type operation on second and third elements so becomes , then you can perform the second type operation on first and second elements, so turns to .
In the fourth test case, it's obvious to see that you can't make any , no matter what you do.
In the fifth test case, you can first perform a type 2 operation on the first three elements so that becomes , then perform a type 2 operation on the elements in positions two through four, so that becomes , and finally perform the first type operation on the remaining elements, so that becomes .
Samples
7
3 2
0 1 0
5 3
1 0 1 1 0
2 2
1 1
4 4
0 0 0 0
6 3
0 0 1 0 0 1
7 5
1 1 1 1 1 1 1
5 3
0 0 1 0 0
YES
YES
YES
NO
YES
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |