#include using namespace std; vector costlyIntervals(int n, int k1, vector A) { // Return a list of length n consisting of the answers vector ans(n,-1); for(int i=0;imax || max==-1){ max=A[k]; } if(A[k]=k1){ int p=j-i+1; for(int k=i;k<=j;k++){ if(ans[k]<=p){ ans[k]=p; } } } } } return ans; } int main() { int n; int k; cin >> n >> k; vector A(n); for(int A_i = 0; A_i < n; A_i++){ cin >> A[A_i]; } 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; }