This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n; cin >> n;
ll m, r = 0; cin >> m;
vector<ll> A(n), X;
for(int i = 0; i < n; i++) cin >> A[i];
int a = n / 2;
for(int msk = 0; msk < (1 << a); msk++) {
ll s = 0;
for(int i = 0; i < a; i++)
if(msk & (1 << i))
s += A[i];
if(s <= m) X.push_back(s);
}
sort(X.begin(), X.end());
for(int msk = 0; msk < (1 << (n - a)); msk++) {
ll s = 0;
for(int i = 0; i < n - a; i++)
if(msk & (1 << i))
s += A[a + i];
r += upper_bound(X.begin(), X.end(), m - s) - X.begin();
}
cout << r;
}
# | 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... |