#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(int i = 0; i < n; ++i) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> m; vector e(n), v(m), w(m), tv(1<> e[i]; rep(i,m) cin >> v[i] >> w[i]; reverse(all(e)); rep(i,1<>j)&1) totv += v[j], totw += w[j]; } tv[i] = totv; tw[i] = min(INF, totw); } vector> dp(n+1,vector(1<(1<e[i]) continue; if(chmax(dp[i+1][j|k], dp[i][j]+tv[k])) par[i+1][j|k] = j; if(!k) break; } } } int state = -1, ans = -1; rep(i,1<>j)&1) cout << j+1 << " "; cout << '\n'; state = x; } return 0; }