#include using namespace std; vector costlyIntervals(int n, int k, vector A) { vector B(n, -1); for (int i = 0; i < n; i++) { int pOR = 0, pAND = -1, pMIN = ~(1<<31), pMAX = (1<<31); int len = -1; for (int j = i; j < n; j++) { pOR |= A[j]; pAND &= A[j]; pMIN = min(pMIN, A[j]); pMAX = max(pMAX, A[j]); int cost = (pOR - pAND) - (pMAX - pMIN); if (cost >= k) len = j; } if (len >= 0) { for (int j = i; j <= len; j++) B[j] = max(B[j], len - i + 1); } } return B; } 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; }