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;
long long n,m,total;
long long arr[41];
int main() {
cin>>n>>m;
for (int i=0;i<n;i++) cin>>arr[i];
vector<long long> sums;
int fh=n/2;
for (int i=0;i<(1<<fh);i++){
long long sum=0;
for (int j=0;j<fh;j++){
if (i&(1<<j)) sum+=arr[j];
}
sums.push_back(sum);
}
sort(sums.begin(),sums.end());
int sh=n-fh;
for (int i=0;i<(1<<sh);i++){
long long sum=0;
for (int j=0;j<sh;j++){
if (i&(1<<j)) sum+=arr[fh+j];
}
sum=m-sum;
int countt=upper_bound(sums.begin(),sums.end(),sum)-sums.begin();
total+=countt;
}
cout<<total;
}
# | 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... |