#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,m;
cin>>n>>m;
long long arr[n];
for(int i = 0;i<n;i++){
cin>>arr[i];
}
long long l = n/2;
vector<long long> v;
for(int i = 0;i<(1<<l);i++){
long long s = 0;
for(int j = 0;j<l;j++){
if(i&(1<<j)){
s+=arr[j];
}
}
v.push_back(s);
}
sort(v.begin(),v.end());
long long all = 0;
for(int i = 0;i<(1<<(n-l));i++){
long long s= 0;
for(int j= l;j<n;j++){
if(i&(1<<(j-l))){
s+=arr[j];
}
}
if(s<=m)all++;
long long it = lower_bound(v.begin(),v.end(),(m-s)+1)-v.begin();
it--;
if(it>=0)all+=it;
}
cout<<all;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
848 KB |
Output is correct |
2 |
Correct |
95 ms |
2428 KB |
Output is correct |
3 |
Correct |
477 ms |
8572 KB |
Output is correct |
4 |
Correct |
97 ms |
2460 KB |
Output is correct |
5 |
Correct |
16 ms |
848 KB |
Output is correct |
6 |
Correct |
7 ms |
596 KB |
Output is correct |
7 |
Correct |
17 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1356 KB |
Output is correct |
2 |
Correct |
32 ms |
848 KB |
Output is correct |
3 |
Correct |
189 ms |
4552 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
7 ms |
596 KB |
Output is correct |
6 |
Correct |
12 ms |
848 KB |
Output is correct |
7 |
Correct |
16 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
1356 KB |
Output is correct |
2 |
Correct |
155 ms |
2480 KB |
Output is correct |
3 |
Correct |
145 ms |
2460 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
93 ms |
2540 KB |
Output is correct |
6 |
Correct |
224 ms |
8616 KB |
Output is correct |
7 |
Correct |
75 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
343 ms |
4488 KB |
Output is correct |
2 |
Correct |
33 ms |
852 KB |
Output is correct |
3 |
Correct |
10 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
7 ms |
596 KB |
Output is correct |
6 |
Correct |
150 ms |
4528 KB |
Output is correct |
7 |
Correct |
13 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
920 KB |
Output is correct |
2 |
Correct |
95 ms |
2500 KB |
Output is correct |
3 |
Correct |
9 ms |
596 KB |
Output is correct |
4 |
Correct |
9 ms |
596 KB |
Output is correct |
5 |
Correct |
110 ms |
2472 KB |
Output is correct |
6 |
Correct |
17 ms |
848 KB |
Output is correct |
7 |
Correct |
237 ms |
8576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
385 ms |
8632 KB |
Output is correct |
2 |
Correct |
30 ms |
940 KB |
Output is correct |
3 |
Correct |
9 ms |
596 KB |
Output is correct |
4 |
Correct |
433 ms |
8584 KB |
Output is correct |
5 |
Correct |
137 ms |
4548 KB |
Output is correct |
6 |
Correct |
12 ms |
848 KB |
Output is correct |
7 |
Correct |
25 ms |
1356 KB |
Output is correct |