/* -*- coding: utf-8 -*- * * 3670.cc: No.3670 Fast Knapsack - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_S = 200000; /* typedef */ using btst = bitset; /* global variables */ int as[MAX_N]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n, s; scanf("%d%d", &n, &s); for (int i = 0; i < n; i++) scanf("%d", as + i); btst dp; dp[0] = 1; for (int i = 0; i < n; i++) dp |= (dp << as[i]); int maxs = 0; for (int i = s; i > 0; i--) if (dp[i]) { maxs = i; break; } printf("%d\n", maxs); } return 0; }