#include <bits/stdc++.h>
#define ll long long
#define MAXN 50
using namespace std;
ll a[MAXN],m,l,r;
vector<ll> v1,v2;
void Solve_1(ll cur,ll pos)
{
if (pos>r)
{
if (cur>m)
return;
v1.push_back(cur);
return;
}
Solve_1(cur,pos+1);
Solve_1(cur+a[pos],pos+1);
}
void Solve_2(ll cur,ll pos)
{
if (pos>r)
{
if (cur>m)
return;
v2.push_back(cur);
return;
}
Solve_2(cur,pos+1);
Solve_2(cur+a[pos],pos+1);
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,ans=0;
cin >> n >> m;
for (ll i=1;i<=n;i++)
cin >> a[i];
l=1;
r=n/2;
Solve_1(0,1);
l=n/2+1;
r=n;
Solve_2(0,n/2+1);
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
for (auto i : v1)
{
auto it=upper_bound(v2.begin(),v2.end(),m-i);
if (it==v2.begin())
continue;
it--;
ans+=it-v2.begin()+1;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 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 |
1 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 |
15 ms |
2008 KB |
Output is correct |
2 |
Correct |
53 ms |
5452 KB |
Output is correct |
3 |
Correct |
219 ms |
20788 KB |
Output is correct |
4 |
Correct |
55 ms |
5432 KB |
Output is correct |
5 |
Correct |
6 ms |
1492 KB |
Output is correct |
6 |
Correct |
5 ms |
856 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
2896 KB |
Output is correct |
2 |
Correct |
17 ms |
1880 KB |
Output is correct |
3 |
Correct |
78 ms |
10568 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
984 KB |
Output is correct |
6 |
Correct |
10 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
3540 KB |
Output is correct |
2 |
Correct |
80 ms |
6608 KB |
Output is correct |
3 |
Correct |
70 ms |
6520 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
32 ms |
6608 KB |
Output is correct |
6 |
Correct |
169 ms |
20852 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
12748 KB |
Output is correct |
2 |
Correct |
17 ms |
1988 KB |
Output is correct |
3 |
Correct |
6 ms |
984 KB |
Output is correct |
4 |
Correct |
0 ms |
316 KB |
Output is correct |
5 |
Correct |
4 ms |
984 KB |
Output is correct |
6 |
Correct |
139 ms |
12748 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2008 KB |
Output is correct |
2 |
Correct |
49 ms |
5452 KB |
Output is correct |
3 |
Correct |
6 ms |
856 KB |
Output is correct |
4 |
Correct |
5 ms |
856 KB |
Output is correct |
5 |
Correct |
35 ms |
6608 KB |
Output is correct |
6 |
Correct |
15 ms |
2008 KB |
Output is correct |
7 |
Correct |
10 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
199 ms |
20804 KB |
Output is correct |
2 |
Correct |
16 ms |
1880 KB |
Output is correct |
3 |
Correct |
6 ms |
984 KB |
Output is correct |
4 |
Correct |
220 ms |
20816 KB |
Output is correct |
5 |
Correct |
50 ms |
10568 KB |
Output is correct |
6 |
Correct |
11 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |