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;
const long long MX=44;
long long pr[MX],st2[MX],a[MX];
long long cnt(long long n,long long k)
{
if(n==0 || k<a[1])
{
return 1;
}
if(pr[n]<=k)
{
return st2[n];
}
long long o=0;
if(a[n]<=k)
{
o=cnt(n-1,k-a[n]);
}
return (o+cnt(n-1,k));
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
long long n,k;
cin>>n>>k;
for(long long i=1;i<=n;i++)
{
cin>>a[i];
}
sort(a+1,a+1+n);
st2[0]=1;
for(long long i=1;i<=n;i++)
{
pr[i]=pr[i-1]+a[i];
st2[i]=(st2[i-1]*2);
}
cout<<cnt(n,k)<<"\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... |