#include [[nodiscard]] static inline constexpr std::pair, std::vector> prepare(const uint_fast32_t N, const std::vector& v, const std::vector& w) noexcept { std::vector csum_v(N + 1, 0), csum_w(N + 1, 0); for (uint_fast32_t i = 0; i < N; ++i) csum_v[i + 1] = csum_v[i] + v[i]; for (uint_fast32_t i = 0; i < N; ++i) csum_w[i + 1] = csum_w[i] + w[i]; return std::make_pair(std::move(csum_v), std::move(csum_w)); } [[nodiscard]] 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 { const auto [csum_v, csum_w] = prepare(N, v, w); std::vector ans, cur; uint_fast32_t max_value = 0, cur_value = 0, cur_weight = 0; const auto dfs = [&](const auto self, const uint_fast32_t cur_pos = 0) constexpr noexcept -> void { if (cur_pos == N) [[unlikely]] { if (max_value < cur_value) max_value = cur_value, ans = cur; return; } if (cur_value + (csum_v[N] - csum_v[cur_pos]) <= max_value) [[unlikely]] return; if (cur_weight + (csum_w[N] - csum_w[cur_pos]) > W) [[likely]] self(self, cur_pos + 1); if (cur_weight + w[cur_pos] <= W) { cur.push_back(cur_pos + 1), cur_value += v[cur_pos], cur_weight += w[cur_pos]; self(self, cur_pos + 1); cur.pop_back(), cur_value -= v[cur_pos], cur_weight -= w[cur_pos]; } }; 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; std::cin >> N >> W; std::vector v(N), w(N); for (auto& v : v) std::cin >> v; for (auto& w : w) std::cin >> w; output(solve(N, W, v, w)); return 0; }