-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode550B.cpp
More file actions
38 lines (29 loc) · 728 Bytes
/
Copy pathcode550B.cpp
File metadata and controls
38 lines (29 loc) · 728 Bytes
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
/*
* Contest : Codeforces
* Problem : 550B - Preparing Olympiad
* Link : https://codeforces.com/problemset/problem/550/B
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
ll n, l, r, x, cnt = 0;
cin >> n >> l >> r >> x;
vector<ll> v(n);
for (auto &i : v) cin >> i;
for (int mask = 0; mask <= (1 << n) - 1; ++mask) {
ll s = 0, high = 0, low = LLONG_MAX;
for (int i = 0; i < n; ++i) {
if (mask & (1 << i)) {
s += v[i];
low = min(low, v[i]);
high = max(high, v[i]);
}
}
if (s >= l && s <= r && high - low >= x) cnt++;
}
cout << cnt << '\n';
return 0;
}