#include using namespace std; int _and(vector::iterator begin, vector::iterator end) { int result = -1; for (auto it = begin; it != end; it++) result &= *it; return result; } int _or(vector::iterator begin, vector::iterator end) { int result = 0; for (auto it = begin; it != end; it++) result |= *it; return result; } int cost(vector::iterator begin, vector::iterator end) { int cost = (_or(begin, end) - _and(begin, end)) - (*max_element(begin, end) - *min_element(begin, end)); return cost; } vector costlyIntervals(int n, int k, vector A) { int _cost[100][100] = {0}; for (int i = 0; i < n; i++) for (int j = i; j < n; j++) for (int k = i; k <= j; k++) _cost[i][j] = cost(A.begin()+i, A.begin()+j+1); vector ans(n, -1); for (int h = 0; h < n; h++) for (int i = h; i >= 0; i--) for (int j = h; j < n; j++) if (_cost[i][j] >= k) ans[h] = max(ans[h], j+1-i); 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; }