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 endl '\n'
using ll=long long;
int a[41];
vector<int>v;
int n,m;
int ans=0;
void rec(int i,int sm){
if(i==n/2){
v.push_back(sm);
return;
}
rec(i+1,sm+a[i]);rec(i+1,sm);
}
void rec2(int i,int sm){
if(i==n){
int idx=upper_bound(v.begin(),v.end(),m-sm)-v.begin();
ans+=idx;
return;
}
rec2(i+1,sm+a[i]);rec2(i+1,sm);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
rec(0,0);
sort(v.begin(),v.end());
rec2(n/2,0);
cout<<ans;
}
# | 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... |