This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |