using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int[] costlyIntervals(int n, int r, int[] A) { // Return a list of length n consisting of the answers int[] ans = new int[n]; var or = new int[n,n]; var and = new int[n,n]; var min = new int[n,n]; var max = new int[n,n]; for(int i = 0; i=0; k--) { for(int i = 0; i < n-k; i++) { int cost = or[i,i+k] - and[i,i+k] - max[i,i+k] + min[i,i+k]; if(cost >= r) { for(int j = i; j < i+k+1; j++) { if(ans[j] < 0) { count += 1; ans[j] = k+1; } } } if(count == n) break; } } return ans; } static void Main(String[] args) { string[] tokens_n = Console.ReadLine().Split(' '); int n = Convert.ToInt32(tokens_n[0]); int k = Convert.ToInt32(tokens_n[1]); string[] A_temp = Console.ReadLine().Split(' '); int[] A = Array.ConvertAll(A_temp,Int32.Parse); int[] result = costlyIntervals(n, k, A); Console.WriteLine(String.Join("\n", result)); } }