#include #include #include #include #include #include #include #include #define MAXN 111111 #define ll long long using namespace std; int arr[MAXN+2]; int ans[MAXN+2]; vector starts[MAXN+2]; vector endss[MAXN+2]; ll MakeHash(ll x, ll y) { return x*(MAXN+1)+y; } int main() { int n,k; cin>>n>>k; for(int i=1;i<=n;i++) cin>>arr[i]; for(int i=1;i<=n;i++) ans[i]=-1; for(int i=1;i<=n;i++) { int O = arr[i]; int A = arr[i]; int MX = arr[i]; int MN = arr[i]; int largest_j = -1; for(int j=i;j<=n;j++) { O |= arr[j]; A &= arr[j]; MX = max(MX, arr[j]); MN = min(MN, arr[j]); if (O-A-MX+MN >= k) { largest_j=max(largest_j, j); } } if (largest_j != -1) { starts[i].push_back(MakeHash(largest_j-i+1,i)); endss[largest_j].push_back(MakeHash(largest_j-i+1,i)); } } set intervals; for(int i=1;i<=n;i++) { for(auto x : endss[i-1]) intervals.erase(x); for(auto x : starts[i]) intervals.insert(x); if (intervals.empty()) cout << -1 << endl; else cout << (*intervals.rbegin()) / (MAXN+1) << endl; } }