欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1810A.Beautiful Sequence
Beautiful Sequence
A sequence of integers is good, if and only if there exists at least one () such that . For example, is a good sequence, since , , while is not a good sequence, since there is no such that .
A sequence is beautiful, if and only if there exists at least one subsequence of satisfying that this subsequence is good. For example, is a beautiful sequence, since its subsequence is good, while is not a beautiful sequence.
A sequence is a subsequence of a sequence if can be obtained from by the deletion of several (possibly, zero or all) elements.
Now you are given a sequence, check whether it is beautiful or not.
Input
Each test contains multiple test cases. The first line contains a single integer () — the number of test cases. Their description follows.
The first line of each test case contains an integer () — the length of the given sequence.
The second line of each test case contains integers (), representing the sequence.
Output
For each test case, output "YES" or "NO"(without quotes) in one line, representing whether the given sequence is beautiful.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Note
In the first test case, the good subsequence is , where .
In the second test case, the good subsequence is , where .
In the fourth test case, the good subsequence is , where .
In the fifth test case, the good subsequence is , where .
Samples
7
3
3 2 1
4
2 4 3 5
5
2 3 5 5 6
2
3 1
5
2 4 5 2 3
4
5 6 7 8
6
6 5 4 3 2 1
YES
YES
NO
YES
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |