//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
ll m;
cin >> n >> m;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int left_sz = n / 2, right_sz = n - left_sz;
int topkek = 1 << right_sz;
vector<ll> weights;
for (int mask = 0; mask < topkek; mask++) {
ll kek = 0;
for (int i = 0; i < right_sz; i++) {
if (mask & (1 << i)) {
kek += a[left_sz + i];
}
}
weights.push_back(kek);
}
topkek = 1 << left_sz;
ll ans = 0;
sort(weights.begin(), weights.end());
for (int mask = 0; mask < topkek; mask++) {
ll kek = 0;
for (int i = 0; i < left_sz; i++) {
if (mask & (1 << i)) {
kek += a[i];
}
}
ans += upper_bound(weights.begin(), weights.end(), m - kek) - weights.begin();
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1528 KB |
Output is correct |
2 |
Correct |
125 ms |
2664 KB |
Output is correct |
3 |
Correct |
583 ms |
8744 KB |
Output is correct |
4 |
Correct |
119 ms |
2536 KB |
Output is correct |
5 |
Correct |
21 ms |
1180 KB |
Output is correct |
6 |
Correct |
10 ms |
760 KB |
Output is correct |
7 |
Correct |
18 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
1524 KB |
Output is correct |
2 |
Correct |
38 ms |
1568 KB |
Output is correct |
3 |
Correct |
259 ms |
4576 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
9 ms |
764 KB |
Output is correct |
6 |
Correct |
20 ms |
988 KB |
Output is correct |
7 |
Correct |
18 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
2544 KB |
Output is correct |
2 |
Correct |
179 ms |
4588 KB |
Output is correct |
3 |
Correct |
173 ms |
4584 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
102 ms |
4568 KB |
Output is correct |
6 |
Correct |
319 ms |
8736 KB |
Output is correct |
7 |
Correct |
120 ms |
4588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
391 ms |
8748 KB |
Output is correct |
2 |
Correct |
36 ms |
1524 KB |
Output is correct |
3 |
Correct |
13 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
11 ms |
760 KB |
Output is correct |
6 |
Correct |
260 ms |
8832 KB |
Output is correct |
7 |
Correct |
17 ms |
1068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1524 KB |
Output is correct |
2 |
Correct |
114 ms |
2544 KB |
Output is correct |
3 |
Correct |
12 ms |
760 KB |
Output is correct |
4 |
Correct |
12 ms |
760 KB |
Output is correct |
5 |
Correct |
123 ms |
4584 KB |
Output is correct |
6 |
Correct |
30 ms |
1524 KB |
Output is correct |
7 |
Correct |
300 ms |
8788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
455 ms |
8672 KB |
Output is correct |
2 |
Correct |
40 ms |
1524 KB |
Output is correct |
3 |
Correct |
13 ms |
760 KB |
Output is correct |
4 |
Correct |
587 ms |
8728 KB |
Output is correct |
5 |
Correct |
153 ms |
4584 KB |
Output is correct |
6 |
Correct |
19 ms |
1020 KB |
Output is correct |
7 |
Correct |
35 ms |
1648 KB |
Output is correct |