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 all(x) begin(x), end(x)
#define sz(x) ((int)size(x))
#define trace(x) cout << #x << ": " << (x) << endl;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
ll m;
cin >> n >> m;
int L = n / 2, R = n - L;
vector<ll> x(1 << R), a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
for (int mask = 0; mask < (1 << R); ++mask) {
for (int i = 0; i < R; ++i) {
if ((mask >> i) & 1) {
x[mask] += a[i + L];
}
}
}
sort(all(x));
ll ans = 0;
for (int mask = 0; mask < (1 << L); ++mask) {
ll sum = 0;
for (int i = 0; i < L; ++i) {
if ((mask >> i) & 1)
sum += a[i];
}
ans += upper_bound(all(x), m - sum) - begin(x);
}
cout << ans;
return 0;
}
# | 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... |