이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |