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 ll long long
void go(int n, vector<ll> &vals){
ll A[n];
for (ll &i : A) cin >> i;
for (int i = 0; i < (1 << n); i++){
ll sm = 0;
for (int j = 0; j < n; j++) if ((i >> j) & 1) sm += A[j];
vals.push_back(sm);
}
sort(vals.begin(), vals.end());
}
int main(){
int N; ll M; cin >> N >> M;
vector<ll> X, Y;
go(N / 2, X); go(N - N / 2, Y);
ll ans = 0;
for (ll i : X) ans += upper_bound(Y.begin(), Y.end(), M - i) - Y.begin();
cout<<ans<<endl;
}
# | 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... |