题意:

思路:

%E7%8E%B0%E5%9C%A8%E8%BD%AE%E5%88%B0%E6%94%BE%E7%AC%ACi%E4%B8%AA%E7%89%A9%E5%93%81%EF%BC%8C%E5%B7%B2%E7%BB%8F%E7%94%A8%E4%BA%86j%E4%B8%AA%E5%88%86%E7%BB%84%EF%BC%8C%E9%82%A3%E4%B9%88%E7%89%A9%E5%93%81i%E5%A6%82%E6%9E%9C%E6%94%BE%E5%BE%97%E4%B8%8B%EF%BC%8C&preview=true)


#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 25;
const int inf = 0x3f3f3f3f;
int a[N],w[N],ans,n,x,W,mx;
void dfs(int x,int cnt){
if(cnt >= ans) return;
if(x > n){
ans = min(ans,cnt);
return;
}
for(int i = 0;i < cnt;i++){
if(w[i] + a[x] <= W){
w[i] += a[x];
dfs(x + 1,cnt);
w[i] -= a[x];
}
}
w[cnt] = a[x];
dfs(x + 1,cnt + 1);
w[cnt] = 0;
}
int main(){
int t;scanf("%d",&t);
while(t--){
mx = -inf;
scanf("%d%d%d",&n,&x,&W);
for(int i = 1;i <= n;i++){
scanf("%d",a + i);
mx = max(mx,a[i]);
}
if(mx > W){puts("No");continue;}
sort(a + 1,a + 1 + n,greater<int>());
ans = n;
dfs(1,1);
if(ans <= x) puts("Yes");
else puts("No");
}
}