#include static inline constexpr std::vector solve(const uint_fast32_t N, const uint_fast32_t W, const std::vector& v, const std::vector& w) noexcept { uint_fast32_t best_value = 0; std::vector ans, cur; ans.reserve(N), cur.reserve(N); using Compare = decltype([](const std::pair& a, const std::pair& b) { return static_cast(a.first) * b.second > static_cast(b.first) * a.second; }); std::multiset, Compare> rest_items; for (uint_fast32_t i = 0; i != N; ++i) rest_items.insert({ v[i], w[i] }); const auto dfs = [&](const auto self, const uint_fast32_t cur_pos = 0, const uint_fast32_t total_value = 0, const uint_fast32_t total_weight = 0) constexpr noexcept -> void { if (total_weight > W) return; else if (cur_pos == N) { if (total_value > best_value) ans = cur, best_value = total_value; return; } uint_fast32_t add_value = 0, add_weight = 0; std::multiset, Compare>::iterator itr; for (itr = rest_items.begin(); itr != rest_items.end() && add_weight + itr->second <= W - total_weight; ++itr) add_value += itr->first, add_weight += itr->second; if (itr != rest_items.end()) { if (total_value + add_value + itr->first * (W - total_weight - add_weight) / static_cast(itr->second) > best_value) { rest_items.erase(rest_items.find({ v[cur_pos], w[cur_pos] })); self(self, cur_pos + 1, total_value, total_weight); cur.push_back(cur_pos + 1); self(self, cur_pos + 1, total_value + v[cur_pos], total_weight + w[cur_pos]); cur.pop_back(); rest_items.insert({ v[cur_pos], w[cur_pos] }); } } else { if (total_value + add_value > best_value) { ans = cur, best_value = total_value + add_value; for (uint_fast32_t i = cur_pos + 1; i <= N; ++i) ans.push_back(i); } } }; dfs(dfs); return ans; } static inline void output(const std::vector& ans) noexcept { std::cout << ans.size() << '\n' << ans[0]; for (uint_fast32_t i = 1; i != ans.size(); ++i) std::cout << ' ' << ans[i]; std::cout << '\n'; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, W, i; std::cin >> N >> W; std::vector v(N), w(N); for (i = 0; i != N; ++i) std::cin >> v[i]; for (i = 0; i != N; ++i) std::cin >> w[i]; output(solve(N, W, v, w)); return 0; }