fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool check (int a[], int n, int x, int k) {
  5. int res=x;
  6. for (int i=0; i<n; i++) res+=a[i];
  7. return res>k;
  8. }
  9.  
  10. int main() {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(nullptr);
  13.  
  14. int t; cin >> t;
  15. while (t--) {
  16. int x, k, n; cin >> x >> k >> n;
  17. int a[n];
  18. for (int i=0; i<n; i++) cin >> a[i];
  19. if (check(a, n, x, k)) cout << "YES" << endl;
  20. else cout << "NO" << endl;
  21. }
  22. }
Success #stdin #stdout 0.01s 5272KB
stdin
1
5
6
3
-1
3
-4
stdout
NO