CF1991F Triangle Formation
题目描述
### 题面描述
你有 $n$ 根棍子,从 $1$ 到 $n$ 编号。第 $i$ 根棍子的长度是 $a_i$。
你需要回答 $q$ 个问题。在每个查询中,你会得到两个整数 $l$ 和 $r$($1 \le l < r \le n,r − l + 1 \le 6$)。确定是否可以从编号为l到r的棒中选择6个不同的棒,形成2个非退化三角形。
边长为 $a$、$b$ 和 $c$ 的三角形称为非退化三角形,当且仅当:
$a
输入格式
第一行包含两个整数 $n$ 和 $q$( $6 \le n \le 10^5,1 \le q \le 10^6$)——分别是条数和查询数。
第二行包含 $n$ 个整数 $a_1、a_2、\cdots、a_n$($1 \le a_i \le 10^9$)—— $a_i$ 表示第 $i$ 根棒的长度。($1 \le l < r \le n,r − l + 1 \le 6$)——每个查询的参数。
输出格式
对于每个查询,如果可以形成 $2$ 个三角形,则输出“YES”(不带引号),否则为“NO”(不带引号)。
在任何情况下都可以输出答案(大小写均可)。例如,字符串“yEs”、“yes”、“YeS”和“YEs”都将被识别为正确答案。
说明/提示
In the first query, the lengths of the sticks are $ [5, 2, 2, 10, 4, 10] $ . Two sets of sticks $ [2, 4, 5] $ and $ [2, 10, 10] $ can be selected to form $ 2 $ non-degenerate triangles.
In the second query, the lengths of the sticks are $ [2, 2, 10, 4, 10, 6] $ . It can be shown that it is impossible to form $ 2 $ non-degenerate triangles.
In the third query, the lengths of the sticks are $ [2, 2, 10, 4, 10, 6, 1] $ . Two sets of sticks $ [1, 2, 2] $ and $ [4, 10, 10] $ can be selected to form $ 2 $ non-degenerate triangles.
In the fourth query, the lengths of the sticks are $ [4, 10, 6, 1, 5, 3] $ . It can be shown that it is impossible to form $ 2 $ non-degenerate triangles.
In the fifth query, the lengths of the sticks are $ [10, 4, 10, 6, 1, 5, 3] $ . Two sets of sticks $ [1, 10, 10] $ and $ [3, 4, 5] $ can be selected to form $ 2 $ non-degenerate triangles.