import sys from collections import deque def main(): N, K = map(int, sys.stdin.readline().split()) a_str = sys.stdin.readline().strip() a = [int(c) for c in a_str] array = a + a # Double the array to handle circularity low = 0.0 high = 1.0 eps = 1e-15 for _ in range(100): mid = (low + high) / 2 # Compute the transformed array and prefix sum prefix = [0.0] * (2 * N + 1) for i in range(2 * N): prefix[i+1] = prefix[i] + (array[i] - mid) # Check using sliding window and deque found = False dq = deque() for i in range(2 * N): if i < K: continue # j = i - K would be negative j = i - K # Maintain deque to add j candidates while dq and prefix[j] <= prefix[dq[-1]]: dq.pop() dq.append(j) # Remove elements out of the left boundary l = max(0, i - N) while dq and dq[0] < l: dq.popleft() if not dq: continue min_j = dq[0] current_sum = prefix[i+1] - prefix[min_j] if current_sum >= -eps: # Allow for small negative due to precision found = True break if found: low = mid else: high = mid # Output with enough precision print("{0:.15f}".format(low).rstrip('0').rstrip('.') if '.' in "{0:.15f}".format(low) else "{0:.15f}".format(low)) if __name__ == "__main__": main()