#include using namespace std; #define LOG(x) std::cout << x << std::endl int cost(int l, int r, vector & A ) { int ors = A[l]; int ands = A[l]; int max = A[l]; int min = A[l]; for (int i = l + 1; i <= r; ++i) { ors |= A[i]; ands &= A[i]; max = std::max(max, A[i]); min = std::min(min, A[i]); } return ((ors - ands) - (max - min)); } vector costlyIntervals(int n, int f, vector & A) { std::vector result(n, -1); for (int i = 0; i < n; ++i) { for (int j = i; j >= 0; --j) { for (int k = i; k < n; ++k) { auto c = cost(j, k, A); //LOG(i << " " << j << " " << k << ": " << c); if (c >= f) { result[i] = std::max(result[i], k - j + 1); } } } } return result; } 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; }