#include using namespace std; int o,a,M,m,lastK; vector resp; vector costlyIntervals(int n, int k, vector A) { // Return a list of length n consisting of the answers for(int i=0; iM) M=A[j]; if(A[j]=k) lastK = j; } for(int j=i; j<=lastK; j++) resp[j] = max(resp[j],lastK-i+1); } return resp; } int main() { int n; int k; cin >> n >> k; vector A(n); resp.resize(n); for(int A_i = 0; A_i < n; A_i++){ cin >> A[A_i]; resp[A_i]=-1; } vector result = costlyIntervals(n, k, A); for (ssize_t i = 0; i < result.size(); i++) { cout << result[i] << (i != result.size() - 1 ? "\n" : ""); } cout << endl; return 0; }