#include <bits/stdc++.h>
#define ll long long
#define vec vector
#define pb push_back
#define pll array<ll, 2>
#define ss second
#define ff first
#define all(X) X.begin(), X.end()
#define allr(X) X.rbegin(), X.rend()
using namespace std;
const ll inf = 1e18;
void _(){
ll n, m, p1, p2; cin >> n >> m;
vec<ll>a(n); for(ll &i : a) cin >> i;
vec<ll>lf, rg; rg.pb(0);
p1 = n / 2; p2 = n - p1;
for(ll i = 0; i < (1 << p1); i++){
ll sm = 0;
for(ll j = 0; j < p1; j++){
if(i & (1 << j)) sm += a[j];
}
lf.pb(sm);
}
sort(all(lf));
for(ll i = 0; i < (1 << p2); i++){
ll sm = 0;
for(ll j = p1; j < n; j++){
if(i & (1 << (j - p1))) sm += a[i];
}
rg.pb(sm);
}
ll ans = 0;
for(ll &i : rg){
ll k = m - i;
ll id = upper_bound(all(lf), k) - lf.begin();
ans += id;
}
cout << ans / 2 << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(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... |