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;
typedef long long ll;
#define FOR(i, a, b) for(ll i = a; i < b; i++)
ll n, m, o, t, sum, ans, a[50], s[1050000];
bitset<50> c;
int main(){
cin >> n >> m; o = n/2; t = n-o;
FOR(i, 0, n) cin >> a[i];
FOR(i, 0, (1 << o)){
c = bitset<50>(i);
FOR(j, 0, o){
if(c.test(j)) s[i] += a[j];
}
}
sort(s, s+(1 << o));
FOR(i, 0, (1 << t)){
c = bitset<50>(i); sum = 0;
FOR(j, 0, t){
if(c.test(j)) sum += a[o+j];
}
ans += upper_bound(s, s+(1<<o), m-sum)-s;
}
cout << ans;
}
# | 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... |