#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include using namespace std; int list[100005]; int main() { int T; cin >> T; while (T--) { int n, cap; cin >> n >> cap; for (int i = 0; i < n; ++i) scanf("%d", &list[i]); sort(list, &list[n]); int total = 0, result = 0; do { total += list[result]; if (total > cap) break; ++result; } while (true); cout << result << endl; } #ifndef ONLINE_JUDGE system("pause"); #endif }