#P6087. [JSOI2015] 送礼物

    ID: 5068 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015二分各省省选单调队列江苏分数规划

[JSOI2015] 送礼物

Description

Assume the gift shop has NN gifts arranged in a line, and each gift has a beauty value. The gift at position i (1iN)i\ (1\leq i\leq N) has a positive integer beauty value AiA_i. JYY decides to choose a consecutive segment, i.e., the gifts numbered i,i+1,,j1,ji,i+1,\cdots,j-1,j. The beauty of the selected gifts is defined as

M(i,j)m(i,j)ji+K\frac{M(i,j)-m(i,j)}{j-i+K}

where M(i,j)M(i,j) denotes max{Ai,Ai+1,,Aj}\max\{A_i,A_{i+1},\cdots,A_j\}, m(i,j)m(i,j) denotes min{Ai,Ai+1,,Aj}\min\{A_i,A_{i+1},\cdots,A_j\}, and KK is a given positive integer.

Since JYY does not want to look stingy, the number of gifts selected must be at least LL. At the same time, selecting too many is hard to carry, so at most RR gifts can be selected. How should JYY choose to obtain the maximum beauty value? Since there are too many gifts to choose from, JYY decides to leave this problem to you, who can program.

Input Format

This problem has multiple test cases in each test point.

The first line contains a positive integer TT, indicating that there are TT test cases.

Each test case consists of two lines. The first line contains four non-negative integers N,K,L,RN,K,L,R. The second line contains NN positive integers, in order, representing A1,A2,,AnA_1,A_2,\cdots,A_n.

Output Format

Output TT lines. Each line contains a non-negative real number, corresponding to the answer for each test case. The testdata guarantees that the answer will not exceed 10310^3. Output the value rounded to 44 decimal places.

1
5 1 2 4
1 2 3 4 5
0.7500

Hint

For 100%100\% of the testdata, T10T\leq 10, N,K5×104N,K\leq 5\times 10^4, 1Ai1081\leq A_i\leq 10^8, 2L,RN2\leq L,R\leq N.

Translated by ChatGPT 5