#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
const int maxn = 45;
int a[maxn];
int n, m;
int ans = 0;
vector<int>v;
void s1(int i, int sum){
if(i == n / 2){
v.push_back(sum);
return;
}
s1(i + 1, sum);
s1(i + 1, sum + a[i]);
}
void s2(int i, int sum){
if(i == n){
auto it = upper_bound(v.begin(), v.end(), m - sum) - v.begin();
ans += it;
return;
}
s2(i + 1, sum);
s2(i + 1, sum + a[i]);
}
signed main(){
cin.tie(0) -> sync_with_stdio(0);
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> a[i];
s1(0, 0);
sort(v.begin(), v.end());
s2(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 |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
500 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 |
70 ms |
3532 KB |
Output is correct |
3 |
Correct |
316 ms |
10692 KB |
Output is correct |
4 |
Correct |
63 ms |
3532 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
6 ms |
1040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1656 KB |
Output is correct |
2 |
Correct |
19 ms |
980 KB |
Output is correct |
3 |
Correct |
119 ms |
6600 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
848 KB |
Output is correct |
6 |
Correct |
7 ms |
1148 KB |
Output is correct |
7 |
Correct |
6 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
1488 KB |
Output is correct |
2 |
Correct |
107 ms |
3532 KB |
Output is correct |
3 |
Correct |
114 ms |
3704 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
23 ms |
3532 KB |
Output is correct |
6 |
Correct |
85 ms |
10692 KB |
Output is correct |
7 |
Correct |
24 ms |
3532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
245 ms |
6600 KB |
Output is correct |
2 |
Correct |
16 ms |
980 KB |
Output is correct |
3 |
Correct |
6 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 |
59 ms |
6600 KB |
Output is correct |
7 |
Correct |
6 ms |
1148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
980 KB |
Output is correct |
2 |
Correct |
61 ms |
3532 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
724 KB |
Output is correct |
5 |
Correct |
29 ms |
3532 KB |
Output is correct |
6 |
Correct |
8 ms |
980 KB |
Output is correct |
7 |
Correct |
97 ms |
10692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
239 ms |
10692 KB |
Output is correct |
2 |
Correct |
20 ms |
980 KB |
Output is correct |
3 |
Correct |
6 ms |
896 KB |
Output is correct |
4 |
Correct |
322 ms |
10692 KB |
Output is correct |
5 |
Correct |
40 ms |
6600 KB |
Output is correct |
6 |
Correct |
7 ms |
1152 KB |
Output is correct |
7 |
Correct |
12 ms |
1488 KB |
Output is correct |