#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) ((int)size(x))
#define trace(x) cout << #x << ": " << (x) << endl;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
ll m;
cin >> n >> m;
int L = n / 2, R = n - L;
vector<ll> x(1 << R), a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
for (int mask = 0; mask < (1 << R); ++mask) {
for (int i = 0; i < R; ++i) {
if ((mask >> i) & 1) {
x[mask] += a[i + L];
}
}
}
sort(all(x));
ll ans = 0;
for (int mask = 0; mask < (1 << L); ++mask) {
ll sum = 0;
for (int i = 0; i < L; ++i) {
if ((mask >> i) & 1)
sum += a[i];
}
ans += upper_bound(all(x), m - sum) - begin(x);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1364 KB |
Output is correct |
2 |
Correct |
100 ms |
2260 KB |
Output is correct |
3 |
Correct |
530 ms |
8532 KB |
Output is correct |
4 |
Correct |
91 ms |
2260 KB |
Output is correct |
5 |
Correct |
16 ms |
724 KB |
Output is correct |
6 |
Correct |
7 ms |
572 KB |
Output is correct |
7 |
Correct |
15 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1364 KB |
Output is correct |
2 |
Correct |
28 ms |
1364 KB |
Output is correct |
3 |
Correct |
185 ms |
4436 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
7 ms |
468 KB |
Output is correct |
6 |
Correct |
13 ms |
724 KB |
Output is correct |
7 |
Correct |
15 ms |
836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
2260 KB |
Output is correct |
2 |
Correct |
141 ms |
4436 KB |
Output is correct |
3 |
Correct |
139 ms |
4308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
76 ms |
4436 KB |
Output is correct |
6 |
Correct |
232 ms |
8532 KB |
Output is correct |
7 |
Correct |
93 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
317 ms |
8532 KB |
Output is correct |
2 |
Correct |
29 ms |
1236 KB |
Output is correct |
3 |
Correct |
10 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
8 ms |
576 KB |
Output is correct |
6 |
Correct |
184 ms |
8532 KB |
Output is correct |
7 |
Correct |
14 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1236 KB |
Output is correct |
2 |
Correct |
93 ms |
2260 KB |
Output is correct |
3 |
Correct |
9 ms |
468 KB |
Output is correct |
4 |
Correct |
10 ms |
468 KB |
Output is correct |
5 |
Correct |
103 ms |
4436 KB |
Output is correct |
6 |
Correct |
23 ms |
1364 KB |
Output is correct |
7 |
Correct |
228 ms |
8512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
8532 KB |
Output is correct |
2 |
Correct |
29 ms |
1236 KB |
Output is correct |
3 |
Correct |
10 ms |
596 KB |
Output is correct |
4 |
Correct |
514 ms |
8532 KB |
Output is correct |
5 |
Correct |
120 ms |
4412 KB |
Output is correct |
6 |
Correct |
14 ms |
724 KB |
Output is correct |
7 |
Correct |
27 ms |
1236 KB |
Output is correct |