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>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 1e7 + 2;
const int inf = 1e9;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
ll m;
cin >> n >> m;
vector<ll> a, b;
for (int i = 0; i < n; i++) {
ll x; cin >> x;
if (i < n / 2) a.push_back(x);
else b.push_back(x);
}
vector<ll> v;
int sza = a.size();
for (int mask = 0; mask < (1 << sza); mask++) {
ll sum = 0;
for (int i = 0; i < sza; i++) {
if ((1 << i) & mask) sum += a[i];
}
v.push_back(sum);
}
sort(v.begin(), v.end());
int szb = b.size();
ll ans = 0;
for (int mask = 0; mask < (1 << szb); mask++) {
ll sum = 0;
for (int i = 0; i < szb; i++) {
if ((1 << i) & mask) sum += b[i];
}
ans += (int)(upper_bound(v.begin(), v.end(), m - sum) - v.begin());
}
cout << ans << en;
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... |