#K95672. Maximum Average Visitor Count
Maximum Average Visitor Count
Maximum Average Visitor Count
Given several test cases, each containing a sequence of daily visitor counts, your task is to compute the maximum average number of visitors over any contiguous window of size \(K\) for each test case. Specifically, for each test case, you are given two integers \(D\) and \(K\) where \(D\) represents the total number of days and \(K\) is the window size. You need to determine the maximal average value computed from any consecutive \(K\) days.
Mathematically, if \(a_1, a_2, \dots, a_D\) are the visitor counts, you must find the maximum value of:
[ \frac{a_i + a_{i+1} + \cdots + a_{i+K-1}}{K} \quad \text{for} \quad 1 \leq i \leq D-K+1 ]
Use a sliding window technique for an efficient solution.
inputFormat
The input is given via stdin and has the following format:
- The first line contains an integer \(T\) representing the number of test cases.
- For each test case, the first line contains two integers \(D\) and \(K\), where \(D\) is the total number of days and \(K\) is the window size.
- The second line of each test case contains \(D\) space-separated integers representing the visitor counts for each day.
outputFormat
For each test case, output a single line to stdout containing the maximum average visitor count computed for that test case. The result should not be rounded.
## sample2
5 2
1 2 3 4 5
7 3
5 1 2 6 4 9 3
4.5
6.333333333333333
</p>