//In the name of Allah
//SMani24
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << endl
#define int long long
using namespace std;
const int N = 42;
int n, m, ans;
int a[N], dpu[N / 2], dpd[N / 2], prep[1 << (N / 2)];
void set_prep() {
for (int i = 0; i < N / 2; i++)
prep[1 << i] = i;
}
void read_input() {
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> a[i];
}
void solve() {
set_prep();
int nu = n / 2, nd = (n + 1) / 2;
for (int mask = 1; mask < (1 << nu); mask++)
dpu[mask] = dpu[mask ^ (mask & -mask)] + a[prep[mask & -mask]];
for (int mask = 1; mask < (1 << nd); mask++)
dpd[mask] = dpd[mask ^ (mask & -mask)] + a[prep[mask & -mask] + nu];
sort(dpu, dpu + (1 << nu));
sort(dpd, dpd + (1 << nd));
for (int i = 0; i < (1 << nu); i++) {
if (dpu[i] > m)
break;
ans += upper_bound(dpd, dpd + (1 << nd), m - dpu[i]) - dpd;
}
}
void write_output() {
cout << ans << endl;
}
int32_t main() {
ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
read_input(), solve(), write_output();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |