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>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define co cout<<
#define ll long long
using namespace std;
//stuff
void solve(){
ll n,k;
cin>>n>>k;
ll arr[n+5];
vector<ll>v;
for(int i=0;i<n;i++) cin>>arr[i];
ll n1=n/2,ans=0;
for(int i=0;i<exp2(n1);i++){
ll sum=0;
ll x=i;
for(int j=0;j<n1;j++) if(((x>>j)&1)) sum+=arr[j];
v.push_back(sum);
}
sort(v.begin(),v.end());
for(int i=0;i<exp2(n-n1);i++){
ll sum=0;
ll x=i;
for(int j=0;j<n-n1;j++) if(((x>>j)&1)) sum+=arr[j+n1];
ans+=upper_bound(v.begin(),v.end(),k-sum)-v.begin();
}
co ans<<'\n';
}
int main(){
suiii
int _=1;
// cin>>_;
while(_--) solve();
}
# | 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... |