#include #include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; u64 testcase(){ int N; cin >> N; u64 W; cin >> W; vector w(N); rep(i,N) cin >> w[i]; vector v(N); v[0] = 1; v[1] = 2; for(int i=2; i dptab = { { 0, W } }; auto dpback = [&]() -> pair { auto i = dptab.end(); i--; return *i; }; auto dpins = [&](map& buf, u64 v, u64 w) -> void { buf[v] = max(buf[v], w); }; u64 ans = 0; for(int i=N-1; i>=0; i--){ u64 maxVsum = 0; for(int j=0; j<=i; j++) maxVsum += v[j]; u64 dpmaxVsum = dpback().first; map buf; for(auto [vv, ww] : dptab){ if(vv + maxVsum <= dpmaxVsum) continue; dpins(buf, vv, ww); if(ww >= w[i]) dpins(buf, vv + v[i], ww - w[i]); } swap(dptab, buf); } ans = dpback().first; return ans; } int main(){ int T; cin >> T; rep(t,T) cout << testcase() << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;