#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, w; cin >> n >> w; vectorp(n), q(n);// 価値、重さ rep(i, n)cin >> p[i]; rep(i, n)cin >> q[i]; vector dp(n + 1, vector

(w + 1, { -INF,-INF }));// 価値、index(生) dp[0][0] = { 0,-1 }; rrep(_i, n)rep(j, w + 1) { int i = n - 1 - _i; int ni = i + 1; if (dp[i][j].first == -INF)continue; {// use int nj = j + q[_i]; int nval = dp[i][j].first + p[_i]; P p = { nval,_i }; if (nj <= w) { chmax(dp[ni][nj], p); } } {//unuse int nj = j + 0; int nval = dp[i][j].first + 0; P p = dp[i][j]; chmax(dp[ni][nj], p); } } int val = 0; rep(i, w + 1)if (dp[n][i].first > 0)val = i;// chmax(val, dp[n][i].first); //cout << val << endl; // cout << dp[n][val].first << " " << dp[n][val].second << endl; //return 0; int idx = n; vectorans; //cout << dp[4][5].first << " " << dp[4][5].second << endl; //cout << dp[1][3].first << " " << dp[1][3].second << endl; //cout << dp[0][0].first << " " << dp[0][0].second << endl; auto[f, s] = dp[n][val]; while (f) { ans.push_back(s); //cout << s << endl; int ff = n - s;//pre->index val -= q[s]; //cout << ff << "_" << val << endl; auto[nf, ns] = dp[ff][val]; f = nf; s = ns; } cout << ans.size() << endl; for (auto e : ans)cout << e + 1 << " "; cout << endl; return 0; }