欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1759B.Lost Permutation
Lost Permutation
A sequence of numbers is called a permutation if it contains all integers from to exactly once. For example, the sequences [], [] and [] are permutations, but [], [] and [] — are not.
Polycarp lost his favorite permutation and found only some of its elements — the numbers . He is sure that the sum of the lost elements equals .
Determine whether one or more numbers can be appended to the given sequence such that the sum of the added numbers equals , and the resulting new array is a permutation?
Input
The first line of input contains a single integer () —the number of test cases.
Then the descriptions of the test cases follow.
The first line of each test set contains two integers and (, )—-the number of found elements and the sum of forgotten numbers.
The second line of each test set contains different integers () — the elements Polycarp managed to find.
Output
Print lines, each of which is the answer to the corresponding test set. Print as the answer YES if you can append several elements to the array , that their sum equals and the result will be a permutation. Output NO otherwise.
You can output the answer in any case (for example, yEs, yes, Yes and YES will be recognized as positive answer).
Note
In the test case of the example, . You can append to the numbers , the sum of which is . Note that the final array will become , which is a permutation.
In the second test case of the example, . You cannot append one or more numbers to such that their sum equals and the result is a permutation.
In the third test case of the example, . You can append the number to . Note that the resulting array will be , which is a permutation.
Samples
5
3 13
3 1 4
1 1
1
3 3
1 4 2
2 1
4 3
5 6
1 2 3 4 5
YES
NO
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |