欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2053A.Tender Carpenter
Tender Carpenter
I would use a firework to announce, a wave to bid farewell, and a bow to say thanks: bygones are bygones; not only on the following path will I be walking leisurely and joyfully, but also the footsteps won't halt as time never leaves out flowing; for in the next year, we will meet again.— Cocoly1990, Goodbye 2022
In his dream, Cocoly would go on a long holiday with no worries around him. So he would try out for many new things, such as... being a carpenter. To learn it well, Cocoly decides to become an apprentice of Master, but in front of him lies a hard task waiting for him to solve.
Cocoly is given an array . Master calls a set of integers stable if and only if, for any possible , , and from the set (note that , , and do not necessarily have to be pairwise distinct), sticks of length , , and can form a non-degenerate triangle.
Cocoly is asked to partition the array into several (possibly, or ) non-empty continuous subsegments, such that: for each of the subsegments, the set containing all the elements in it is stable.
Master wants Cocoly to partition in at least two different ways. You have to help him determine whether it is possible.
A triangle with side lengths , , and is called non-degenerate if and only if:
- ,
- , and
- .
A sequence is a subsegment of a sequence if can be obtained from by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
Two partitions are considered different if and only if at least one of the following holds:
- the numbers of continuous subsegments split in two partitions are different;
- there is an integer such that the lengths of the -th subsegment in two partitions are different.
Input
Each test contains multiple test cases. The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the length of the array .
The second line contains integers () — the elements in the array .
Output
For each test case, print YES if there are at least two ways to partition , and NO otherwise.
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, here are two possible partitions:
- , since
- is stable because sticks of lengths respectively can all form non-degenerate triangles.
- is stable because sticks of lengths respectively can all form non-degenerate triangles.
- and , since
- is stable because sticks of lengths respectively can form a non-degenerate triangle.
- is stable because sticks of lengths respectively can all form non-degenerate triangles.
- is stable because sticks of lengths respectively can form a non-degenerate triangle.
Note that some other partitions also satisfy the constraints, such as and .
In the second test case, Cocoly can only partition each element as a single subsegment, resulting in . Since we only have one possible partition, the answer is NO.
In the third test case, please note that the partition does not satisfy the constraints, because is not a stable set: sticks of lengths , , and cannot form a non-degenerate triangle.
Samples
5
4
2 3 5 7
4
115 9 2 28
5
8 4 1 6 2
6
1 5 4 1 4 7
2
100000 100000
YES
NO
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |