#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 42;
int n, m, ans, a[maxn];
vector <int> v;
int32_t main() {
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> a[i];
for (int msk = 0; msk < (1 << (n / 2)); msk++) {
int S = 0;
for (int j = 0; j < n / 2; j++) {
if (msk & (1 << j)) S += a[j];
}
v.push_back(S);
}
sort(v.begin(), v.end());
for (int msk = 0; msk < (1 << (n - (n / 2))); msk++) {
int S = 0;
for (int j = 0; j < n - (n / 2); j++) {
if (msk & (1 << j)) S += a[j + (n / 2)];
}
ans += upper_bound(v.begin(), v.end(), m - S) - v.begin();
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1012 KB |
Output is correct |
2 |
Correct |
115 ms |
2512 KB |
Output is correct |
3 |
Correct |
571 ms |
8672 KB |
Output is correct |
4 |
Correct |
109 ms |
2540 KB |
Output is correct |
5 |
Correct |
21 ms |
1012 KB |
Output is correct |
6 |
Correct |
11 ms |
760 KB |
Output is correct |
7 |
Correct |
20 ms |
1012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
1392 KB |
Output is correct |
2 |
Correct |
40 ms |
1008 KB |
Output is correct |
3 |
Correct |
210 ms |
4584 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
12 ms |
760 KB |
Output is correct |
6 |
Correct |
20 ms |
1012 KB |
Output is correct |
7 |
Correct |
19 ms |
1012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
1520 KB |
Output is correct |
2 |
Correct |
182 ms |
2540 KB |
Output is correct |
3 |
Correct |
171 ms |
2536 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
103 ms |
2540 KB |
Output is correct |
6 |
Correct |
273 ms |
8668 KB |
Output is correct |
7 |
Correct |
88 ms |
2536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
370 ms |
4580 KB |
Output is correct |
2 |
Correct |
42 ms |
1012 KB |
Output is correct |
3 |
Correct |
16 ms |
760 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
13 ms |
760 KB |
Output is correct |
6 |
Correct |
202 ms |
4580 KB |
Output is correct |
7 |
Correct |
20 ms |
1012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
1012 KB |
Output is correct |
2 |
Correct |
105 ms |
2540 KB |
Output is correct |
3 |
Correct |
14 ms |
760 KB |
Output is correct |
4 |
Correct |
14 ms |
760 KB |
Output is correct |
5 |
Correct |
130 ms |
2536 KB |
Output is correct |
6 |
Correct |
25 ms |
1012 KB |
Output is correct |
7 |
Correct |
270 ms |
8684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
421 ms |
8668 KB |
Output is correct |
2 |
Correct |
42 ms |
1012 KB |
Output is correct |
3 |
Correct |
15 ms |
760 KB |
Output is correct |
4 |
Correct |
569 ms |
8668 KB |
Output is correct |
5 |
Correct |
156 ms |
4580 KB |
Output is correct |
6 |
Correct |
19 ms |
1016 KB |
Output is correct |
7 |
Correct |
35 ms |
1516 KB |
Output is correct |