#include #include #include using namespace std; bool canFillBox(int N, const vector& toys, int c) { // dp[i] indicates if we can fill exactly i capacity with given toys and fillers vector dp(N + 1, false); dp[0] = true; for (int toy : toys) { for (int j = N; j >= toy; --j) { if (dp[j - toy]) { dp[j] = true; } } } // After using all toys, check if we can fill the remaining space with fillers return dp[N] || (N <= c); } int main() { int T; cin >> T; vector res; while (T--) { int N, n, c; cin >> N >> n >> c; vector toys(n); for (int i = 0; i < n; ++i) { cin >> toys[i]; } if (canFillBox(N, toys, c)) { res.push_back("YES"); } else { res.push_back("NO"); } } for(int i = 0; i < res.size(); i++){ cout << res[i] << endl; } return 0; }