#include <bits/stdc++.h>
#define int long long
#define lowval(x) (x & (-x))
#define lowind __builtin_ctzll
using namespace std;
const int MAXN = 40 + 3;
int n, m, c[MAXN], dp[(1 << (MAXN >> 1))], pd[(1 << (MAXN >> 1))], ans;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> c[i];
for (int i = 1; i < (1 << (n >> 1)); i++) dp[i] = c[lowind(i)] + dp[i - lowval(i)];
for (int i = 1; i < (1 << (n - (n >> 1))); i++) pd[i] = c[lowind(i) + (n >> 1)] + pd[i - lowval(i)];
sort(dp, dp + (n >> 1));
sort(pd, pd + n - (n >> 1));
for (int i = 0, j = (1 << (n - (n >> 1))) - 1; i < (1 << (n >> 1)); i++) {
while (~j && pd[j] + dp[i] > m) j--;
ans += j + 1;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
12640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
16716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |