4954. 挑选
作者:
jy9
,
2024-10-07 15:28:47
,
所有人可见
,
阅读 2
#include <iostream>
#include <limits.h>
using namespace std;
const int N = 20;
int n, l, r, x;
int a[N];
int ans = 0;
void dfs(int num, int count, int sum, int mina, int maxa){
if(num == n+1){
if(count >= 2 && sum >= l && sum <= r && maxa-mina >= x) ans++;
return;
}
dfs(num+1, count+1, sum+a[num], min(mina, a[num]), max(maxa, a[num]));
dfs(num+1, count, sum, mina, maxa);
}
int main(){
cin >> n >> l >> r >> x;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
dfs(1, 0, 0, INT_MAX, 0);
cout << ans;
return 0;
}