#P6087. [JSOI2015] 送礼物
[JSOI2015] 送礼物
Background
The wedding anniversary of JYY and CX is coming soon, and JYY comes to the gift shop run by Mengmeng to buy a commemorative gift.
Mengmeng’s gift shop is magical: all gifts for sale are arranged in a line in a fixed order, and there is a mysterious sense of beauty between adjacent gifts. So, JYY decides to choose a consecutive segment of gifts, but which ones should be chosen?
Problem Description
Assume the gift shop has gifts arranged in a line, and each gift has a beauty value. The gift at position has a positive integer beauty value . JYY decides to choose a consecutive segment, i.e., the gifts numbered . The beauty of the selected gifts is defined as
where denotes , denotes , and is a given positive integer.
Since JYY does not want to look stingy, the number of gifts selected must be at least . At the same time, selecting too many is hard to carry, so at most 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 , indicating that there are test cases.
Each test case consists of two lines. The first line contains four non-negative integers . The second line contains positive integers, in order, representing .
Output Format
Output 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 . Output the value rounded to decimal places.
1
5 1 2 4
1 2 3 4 5
0.7500
Hint
For of the testdata, , , , .
Translated by ChatGPT 5