using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int cost(int[] array, int max, int min) { int or = array[0]; int and = array[0]; for(int i = 1; i < array.Length; i++) { or |= array[i]; and &= array[i]; } return ((or -and) - (max - min)); } static int[] costlyIntervals(int n, int k, int[] A) { // Return a list of length n consisting of the answers int[] result = new int[n]; for(int i = 0; i < n; i++) result[i] = -1; for(int i = 0; i < A.Length; i++) { int size = 1; while((size + i) < A.Length) { int[] subarray = new int[size]; int min = int.MaxValue; int max = int.MinValue; for(int s = i; s < i + size; s++) { subarray[s-i] = A[s]; if(A[s] > max) max = A[s]; if(A[s] < min) min = A[s]; } int c = cost(subarray, max, min); if(c >= k) { for(int y = i; y < size + i; y++) { result[y] = size; } } size++; } } return result; } 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)); } }