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;
vector < long long > vr1;
long long a[44];
long long ans,n,k;
void cnt1(long long zr,long long sm)
{
if(zr==(n/2+1))
{
vr1.push_back(sm);
return;
}
cnt1(zr+1,sm+a[zr]);
cnt1(zr+1,sm);
}
void cnt2(long long zr,long long sum)
{
if(zr==n+1)
{
ans+=(upper_bound(vr1.begin(),vr1.end(),k-sum)-vr1.begin());
return;
}
cnt2(zr+1,sum+a[zr]);
cnt2(zr+1,sum);
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n>>k;
for(long long i=1;i<=n;i++)
{
cin>>a[i];
}
cnt1(1,0);
sort(vr1.begin(),vr1.end());
cnt2(n/2+1,0);
cout<<ans<<"\n";
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... |