#include #include #include using namespace std; int main(void) { int n, k; scanf("%i %i", &n, &k); vector a(n); for (int i = 0; i < n; i++) { scanf("%i", &a[i]); } vector ans(n, -1), f(n); for (int i = 0; i < n; i++) { int Or = a[i], And = a[i]; int mini = a[i], maxi = a[i]; for (int j = i; j < n; j++) { Or |= a[j]; And &= a[j]; mini = min(mini, a[j]); maxi = max(maxi, a[j]); int cost = (Or - And) - (maxi - mini); if (cost >= k) { f[j] = j - i + 1; } else { f[j] = -1; } } for (int j = n-1; j >= i; j--) { if (j+1 < n) { f[j] = max(f[j], f[j+1]); } ans[j] = max(f[j], ans[j]); } } for (int i = 0; i < n; i++) { printf("%i\n", ans[i]); } return 0; }