EISW2 - Maximum Average Subarray
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
You are given an integer array nums consisting of n elements, and an integer k.
Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. Any answer with a calculation error less than 10-2 will be accepted.
Input
The first line contains 2 integers n and k, which are the length of nums and the length of subarrays, relatively.
The second line contains n integers which are the elements of nums.
Output
The maximum average
Example
Input
6 4
1 12 -5 -6 50 3
Output
12.75
Bình luận