2019 Fall KBTU OPEN
Temirulan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of blue and red colored beads.
Temirulan already has one that consists of n beads. He knows that his girlfriend prefers red color over blue, so he decided to cut some subsequence of at least k beads from the original necklace such that the ratio between red ones and the number of chosen beads will be maximized.
Can you help him to find this maximum ratio?
The first line contains two integers n, k (1 ≤ k ≤ n ≤ 5 *
105) - the number of beads on the thread and lower-bound of beads for the new necklace.
The second line contains the sequence of n integers separated by a single space
ai (0 ≤
ai ≤ 1) - description of the original necklace.
ai = 0 corresponds to blue and
ai = 1 corresponds to red color.
8 4 11101110
8 4 11011001
10 4 1001001001