#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll=long long;
ll a[41];
vector<ll>v;
int n;
ll m;
ll ans=0;
void rec(int i,ll sm){
if(i==n/2){
v.push_back(sm);
return;
}
rec(i+1,sm+a[i]);rec(i+1,sm);
}
void rec2(int i,ll sm){
if(i==n){
int idx=upper_bound(v.begin(),v.end(),m-sm)-v.begin();
ans+=idx;
return;
}
rec2(i+1,sm+a[i]);rec2(i+1,sm);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
rec(0,0);
sort(v.begin(),v.end());
rec2(n/2,0);
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
980 KB |
Output is correct |
2 |
Correct |
69 ms |
3700 KB |
Output is correct |
3 |
Correct |
325 ms |
10692 KB |
Output is correct |
4 |
Correct |
68 ms |
3532 KB |
Output is correct |
5 |
Correct |
7 ms |
980 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
7 |
Correct |
6 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1488 KB |
Output is correct |
2 |
Correct |
18 ms |
980 KB |
Output is correct |
3 |
Correct |
134 ms |
6772 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
724 KB |
Output is correct |
6 |
Correct |
7 ms |
1144 KB |
Output is correct |
7 |
Correct |
6 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
1660 KB |
Output is correct |
2 |
Correct |
117 ms |
3532 KB |
Output is correct |
3 |
Correct |
130 ms |
3532 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
25 ms |
3532 KB |
Output is correct |
6 |
Correct |
88 ms |
10692 KB |
Output is correct |
7 |
Correct |
25 ms |
3532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
265 ms |
6600 KB |
Output is correct |
2 |
Correct |
17 ms |
1148 KB |
Output is correct |
3 |
Correct |
7 ms |
724 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
724 KB |
Output is correct |
6 |
Correct |
60 ms |
6600 KB |
Output is correct |
7 |
Correct |
7 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
980 KB |
Output is correct |
2 |
Correct |
63 ms |
3532 KB |
Output is correct |
3 |
Correct |
5 ms |
724 KB |
Output is correct |
4 |
Correct |
5 ms |
848 KB |
Output is correct |
5 |
Correct |
29 ms |
3532 KB |
Output is correct |
6 |
Correct |
8 ms |
1104 KB |
Output is correct |
7 |
Correct |
98 ms |
10692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
10692 KB |
Output is correct |
2 |
Correct |
23 ms |
980 KB |
Output is correct |
3 |
Correct |
7 ms |
848 KB |
Output is correct |
4 |
Correct |
338 ms |
10692 KB |
Output is correct |
5 |
Correct |
42 ms |
6600 KB |
Output is correct |
6 |
Correct |
7 ms |
980 KB |
Output is correct |
7 |
Correct |
13 ms |
1488 KB |
Output is correct |