-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcf-A - Replacing Elements - code.cpp
More file actions
46 lines (43 loc) · 1.44 KB
/
cf-A - Replacing Elements - code.cpp
File metadata and controls
46 lines (43 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define inf LLONG_MAX
#define ninf LLONG_MIN
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(s) s.begin(),s.end()
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rr(v) for(auto &val:v)
#define _max(v) *max_valment(v.begin(), v.end())
#define _min(v) *min_valment(v.begin(), v.end())
#define ms(s, n) memset(s, n, sizeof(s))
ll power(ll x, ll y){ll res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
ll powermod(ll x, ll y, ll p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a % b);}
ll fact(ll n){ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r));}
#define print(v) rep(i, 0, v.size()) cout<< v[i]<< " "; cout<< endl;
#define mod 1e9+7
int main()
{
io;
ll t; cin >> t;
//t=1;
while(t--)
{
ll n, d, x, f=1;
vector<ll> v;
cin >> n >> d;
rep(i, 0, n)
{
cin >> x; v.pb(x);
if(x>d) f=0;
}
sort(all(v));
ll first=v[0]+v[1];
//cout<< first << " " << f << endl;
if(f==1 || first<=d) cout<< "YES\n";
else cout<< "NO\n";
}
return 0;
}