import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int[] costlyIntervals(int n, int k, int[] A) { // Return a list of length n consisting of the answers int l,r; int min, max; int arr[] = new int[n]; Arrays.fill(arr, -1); for(int i=0;i=k){ int m = l; int s = r-l+1; while(m<=r){ arr[m] = s; m+=1; } } for(int j=i;jmax) max = A[j]; if(A[j]=k){ int m = l; int s = r-l+1; while(m<=r){ arr[m] = s; m+=1; } } } } return arr; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] A = new int[n]; for(int A_i = 0; A_i < n; A_i++){ A[A_i] = in.nextInt(); } int[] result = costlyIntervals(n, k, A); for (int i = 0; i < result.length; i++) { System.out.print(result[i] + (i != result.length - 1 ? "\n" : "")); } System.out.println(""); in.close(); } }