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 int long long
#define ff first
#define ss second
#define pb push_back
#define inf 1e18
const int N=45;
int arr[N];
signed main(){
int n,x;
cin>>n>>x;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
vector<int>v,vc;
for(int i=1;i<=n/2;i++){
v.pb(arr[i]);
}
for(int i=n/2+1;i<=n;i++){
vc.pb(arr[i]);
}
vector<int>mp1,mp2;
int m=v.size();
for(int i=0;i<(1<<m);i++){
int s=0;
for(int j=0;j<m;j++){
if(i & (1<<j)){
s+=v[j];
}
}
mp1.pb(s);
}
m=vc.size();
for(int i=0;i<(1<<m);i++){
int s=0;
for(int j=0;j<m;j++){
if(i & (1<<j)){
s+=vc[j];
}
}
mp2.pb(s);
}
sort(mp2.begin(),mp2.end());
sort(mp1.begin(),mp1.end());
int cnt=0;
for(auto a:mp1){
auto up=upper_bound(mp2.begin(),mp2.end(),x-a);
cnt+=up-mp2.begin();
}
cout<<cnt;
}
# | 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... |