Pinely Round 4 (Div. 1 + Div. 2)
F
Triangle Formation
Codeforces
2200
原题
← EG →
翻译中…

You are given $n$ sticks, numbered from $1$ to $n$. The length of the $i$-th stick is $a_i$.

翻译中…

You need to answer $q$ queries. In each query, you are given two integers $l$ and $r$ ($1 \le l \lt r \le n$, $r - l + 1 \ge 6$). Determine whether it is possible to choose $6$ distinct sticks from the sticks numbered $l$ to $r$, to form $2$ non-degenerate triangles$^{\text{∗}}$.

翻译中…

$^{\text{∗}}$A triangle with side lengths $a$, $b$, and $c$ is called non-degenerate if: $a \lt b + c$, $b \lt a + c$, and $c \lt a + b$.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $q$ ($6 \le n \le 10^5$, $1 \le q \le 10^5$) — the number of sticks and the number of queries respectively.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — $a_i$ denotes the length of the $i$-th stick.

翻译中…

Each of the following $q$ lines contains two integers $l$ and $r$ ($1 \le l \lt r \le n$, $r - l + 1 \ge 6$) — the parameters of each query.

翻译中…

Output

翻译中…

For each query, output "YES" (without quotes) if it is possible to form $2$ triangles, and "NO" (without quotes) 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 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.

翻译中…

样例

Input #1
10 5
5 2 2 10 4 10 6 1 5 3
1 6
2 7
2 8
5 10
4 10
Output #1
YES
NO
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
1991F
时间限制
5 s
内存限制
256 MB
标签
暴力
贪心
模拟
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。