luogu#P7795. [COCI 2014/2015 #7] PROSJEK

    ID: 7128 远端评测题 1000ms 64MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>2014二分单调队列Special JudgeCOCI(克罗地亚)

[COCI 2014/2015 #7] PROSJEK

Problem Description

Given a sequence aa of nn integers, find a contiguous subsequence of length at least kk such that the average value of all numbers in this subsequence is as large as possible.

Input Format

The input has 22 lines.

The first line contains two integers n,kn, k.
The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n, representing all elements of the sequence aa.

Output Format

Output one line containing a real number, representing the maximum average value among all contiguous subsequences with length at least kk.

For each test point, your program will pass if the relative error between your output and the standard answer does not exceed 10310^{-3}.

4 1
1 2 3 4
4.000000
4 2
2 4 3 4
3.666666
6 3
7 1 2 1 3 6
3.333333

Hint

Constraints

For 30%30\% of the testdata, n5000n \leqslant 5000.
For all testdata, 1kn3×1051 \leqslant k \leqslant n \leqslant 3 \times 10^5, and 1ai1061 \leqslant a_i \leqslant 10^6.

Source

This problem comes from COCI 2014-2015 CONTEST 7 T5 PROSJEK. With the original testdata configuration, the full score is 140140 points.

Translated and organized by Eason_AC.

Translated by ChatGPT 5