#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 2e5+1;
int n;
ll m, a[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; cin >> a[i++]);
vector<ll> sums;
for (int msk = 0; msk < (1 << (n/2)); msk++) {
ll sum = 0;
for (int i = 0; i < n/2; i++) {
if (msk>>i&1) {
sum += a[i];
}
}
sums.push_back(sum);
}
sort(sums.begin(), sums.end());
ll sol = 0;
for (int msk = 0; msk < (1 << (n/2 + n%2)); msk++) {
ll sum = 0;
for (int i = 0; i < n/2+n%2; i++) {
if (msk>>i&1) {
sum += a[n/2+i];
}
}
int idx = upper_bound(sums.begin(), sums.end(), m-sum)-sums.begin();
assert(sum + sums[idx - 1] <= m);
sol += idx;
}
cout << sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
608 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
996 KB |
Output is correct |
2 |
Runtime error |
67 ms |
5068 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
32 ms |
2784 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
2784 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
254 ms |
5824 KB |
Output is correct |
2 |
Correct |
19 ms |
996 KB |
Output is correct |
3 |
Correct |
8 ms |
864 KB |
Output is correct |
4 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
996 KB |
Output is correct |
2 |
Correct |
72 ms |
2528 KB |
Output is correct |
3 |
Correct |
6 ms |
864 KB |
Output is correct |
4 |
Runtime error |
4 ms |
1252 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
284 ms |
9808 KB |
Output is correct |
2 |
Runtime error |
17 ms |
1760 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |