COCI '14 Contest 7 #5 Prosjek

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 0.6s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are given an array of N integers. Find a consecutive subsequence of numbers of the length at least K that has the maximal possible average.

Please note: the average of a subsequence is the sum of all the numbers in the subsequence divided by its length.


The first line of input contains two integers N (1 \le N \le 3\cdot10^5) and K (1 \le K \le N). The second line of input contains N integers a_i (1 \le a_i \le 10^6)


The first and only line of output must contain the maximal possible average. An absolute deviation of \pm0.001 from the official solution is permitted.


In test cases worth 30% of total points, it will hold that N is not larger than 5\,000.

Sample Input 1

4 1
1 2 3 4

Sample Output 1


Sample Input 2

4 2
2 4 3 4

Sample Output 2


Sample Input 3

6 3
7 1 2 1 3 6

Sample Output 3



  • 1
    Y  commented on Aug. 11, 2019, 6:54 p.m.

    Please notice that it is expected to output finite number of digits after the decimal.