#P10882. [JRKSJ R9] ZYPRESSEN

[JRKSJ R9] ZYPRESSEN

Background

The atmosphere is becoming clearer and clearer.
Silent cypresses stand straight up into the sky.

Under the dazzling sky,
sorrow is still deep green.
Cypress trees sway quietly.
Birds once again cut through the blue sky.
There are no sincere words left here.
Asura’s tears fall like rain onto the soil.

Problem Description

It is already completely autumn.

Even so, cypresses (ZYPRESSEN) are probably as dark as ever.

You are given a sequence aa of length nn. There are qq queries, each query is as follows:

  • You are given an interval [l,r][l, r]. For all i,j,ki, j, k satisfying li<j<krl \le i < j < k \le r, if a triangle with side lengths ai,aj,aka_i, a_j, a_k exists, you need to find the minimum value of ai+aj+aka_i + a_j + a_k.

When the three side lengths are a,b,ca, b, c (abc)(a \le b \le c), they can form a triangle if and only if a+b>ca + b > c.

Input Format

The first line contains two integers n,qn, q.

The second line contains nn integers a1na_{1\dots n}.

The next qq lines each contain two integers l,rl, r, representing a query.

Output Format

Output qq lines, one integer per line representing the answer. If there is no valid i,j,ki, j, k, output yumi!.

7 6
3 11 1 5 12 19 10
1 1
3 5
2 5
1 7
2 6
1 4
yumi!
yumi!
28
24
28
yumi!
20 20
26 17 11 89 56 33 72 73 43 77 80 87 97 17 43 74 72 91 49 69
10 19
2 4
3 5
2 11
1 12
10 19
3 5
8 15
8 12
14 20
5 11
13 18
2 18
17 19
1 9
5 8
9 12
1 11
4 13
3 18
109
yumi!
yumi!
87
54
109
yumi!
103
193
109
132
163
45
212
54
161
200
54
132
87

Hint

Sample Explanation 1

For the interval [3,5][3, 5], since 1+5<121 + 5 < 12, there is no valid triangle.

For the intervals [2,5][2, 5] and [2,6][2, 6], choose ai=11,aj=5,ak=12a_i = 11, a_j = 5, a_k = 12.

For the interval [1,7][1, 7], choose ai=3,aj=11,ak=10a_i = 3, a_j = 11, a_k = 10.

Constraints

This problem uses bundled testdata.

Subtask\mathrm{Subtask} nn \le qq \le Special Property Score
11 5×1035 \times 10^3 1010
22 5×1045 \times 10^4 2525
33 2.5×1052.5 \times 10^5 5×1055 \times 10^5 \checkmark 1010
44 5555

Special Property: it is guaranteed that aia_i is generated uniformly at random within the range.

For all testdata, it is guaranteed that 1n2.5×1051 \le n \le 2.5 \times 10^5, 1q5×1051 \le q \le 5 \times 10^5, 1ai1071 \le a_i \le 10^7, and 1lrn1 \le l \le r \le n.

Translated by ChatGPT 5