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 ll long long
const int nx=42;
ll n, v[nx], m, h, res;
vector<ll> s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=0; i<n; i++) cin>>v[i];
h=n/2;
for (int i=0; i<(1<<h); i++)
{
ll sm=0;
for (int j=0; j<h; j++) if (i&(1<<j)) sm+=v[j];
s.push_back(sm);
}
sort(s.begin(), s.end());
//for (auto x:s) cout<<x<<'\n';
for (int i=0; i<(1<<(n-h)); i++)
{
ll sm=0;
for (int j=0; j<h; j++) if (i&(1<<j)) sm+=v[h+j];
if (sm<=m) res+=(upper_bound(s.begin(), s.end(), res)-s.begin());
}
cout<<res;
}
# | 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... |