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;
long long int n,m,i,j,a[42],mid,sum,ans;
vector <long long int> v;
int main()
{
cin>>n>>m;
for(i=0;i<n;i++)
{
cin>>a[i];
}
mid=n/2+1;
for(i=0;i<(1<<mid);i++)
{
for(j=0;j<mid;j++)
{
if((i>>j)&1)
{
sum+=a[j];
}
}
v.push_back(sum);
sum=0;
}
int fn=mid;
mid=n-mid;
sort(v.begin(),v.end());
for(i=0;i<(1<<mid);i++)
{
for(j=0;j<mid;j++)
{
if((i>>j)&1)
{
sum+=a[j+fn];
}
}
if(sum>m)continue;
ans+=upper_bound(v.begin(),v.end(),m-sum)-v.begin();
sum=0;
}
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... |