#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 |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
888 KB |
Output is correct |
2 |
Correct |
123 ms |
2432 KB |
Output is correct |
3 |
Correct |
553 ms |
8696 KB |
Output is correct |
4 |
Correct |
121 ms |
2424 KB |
Output is correct |
5 |
Correct |
19 ms |
888 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
18 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1400 KB |
Output is correct |
2 |
Correct |
40 ms |
920 KB |
Output is correct |
3 |
Correct |
233 ms |
4592 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
9 ms |
656 KB |
Output is correct |
6 |
Correct |
20 ms |
760 KB |
Output is correct |
7 |
Correct |
19 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
1396 KB |
Output is correct |
2 |
Correct |
200 ms |
2424 KB |
Output is correct |
3 |
Correct |
191 ms |
2420 KB |
Output is correct |
4 |
Correct |
2 ms |
252 KB |
Output is correct |
5 |
Correct |
106 ms |
2552 KB |
Output is correct |
6 |
Correct |
312 ms |
8572 KB |
Output is correct |
7 |
Correct |
102 ms |
2420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
416 ms |
4472 KB |
Output is correct |
2 |
Correct |
35 ms |
884 KB |
Output is correct |
3 |
Correct |
13 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
10 ms |
504 KB |
Output is correct |
6 |
Correct |
234 ms |
4472 KB |
Output is correct |
7 |
Correct |
18 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
888 KB |
Output is correct |
2 |
Correct |
116 ms |
2424 KB |
Output is correct |
3 |
Correct |
12 ms |
632 KB |
Output is correct |
4 |
Correct |
12 ms |
632 KB |
Output is correct |
5 |
Correct |
132 ms |
2424 KB |
Output is correct |
6 |
Correct |
28 ms |
1016 KB |
Output is correct |
7 |
Correct |
304 ms |
8696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
483 ms |
8572 KB |
Output is correct |
2 |
Correct |
41 ms |
1016 KB |
Output is correct |
3 |
Correct |
13 ms |
504 KB |
Output is correct |
4 |
Correct |
570 ms |
8540 KB |
Output is correct |
5 |
Correct |
156 ms |
4496 KB |
Output is correct |
6 |
Correct |
19 ms |
888 KB |
Output is correct |
7 |
Correct |
36 ms |
1528 KB |
Output is correct |