#include <bits/stdc++.h>
#define ll long long
#define MAXN 50
using namespace std;
ll a[MAXN],m;
vector<ll> v1,v2;
void Solve(ll l,ll r,ll cur,ll pos,vector<ll> &v)
{
if (pos>r)
{
if (cur<=m)
v.push_back(cur);
return;
}
Solve(l,r,cur,pos+1,v);
Solve(l,r,cur+a[pos],pos+1,v);
}
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];
Solve(1,n/2,0,1,v1);
Solve(n/2+1,n,0,n/2+1,v2);
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 |
1 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 |
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 |
1 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 |
340 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 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 |
15 ms |
2008 KB |
Output is correct |
2 |
Correct |
55 ms |
5452 KB |
Output is correct |
3 |
Correct |
214 ms |
20760 KB |
Output is correct |
4 |
Correct |
49 ms |
5452 KB |
Output is correct |
5 |
Correct |
7 ms |
1492 KB |
Output is correct |
6 |
Correct |
5 ms |
984 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
2776 KB |
Output is correct |
2 |
Correct |
18 ms |
2008 KB |
Output is correct |
3 |
Correct |
75 ms |
10568 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
856 KB |
Output is correct |
6 |
Correct |
10 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3540 KB |
Output is correct |
2 |
Correct |
70 ms |
6608 KB |
Output is correct |
3 |
Correct |
70 ms |
6608 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
31 ms |
6608 KB |
Output is correct |
6 |
Correct |
160 ms |
20828 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
12712 KB |
Output is correct |
2 |
Correct |
16 ms |
1880 KB |
Output is correct |
3 |
Correct |
6 ms |
856 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
3 ms |
856 KB |
Output is correct |
6 |
Correct |
149 ms |
12748 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2008 KB |
Output is correct |
2 |
Correct |
51 ms |
5452 KB |
Output is correct |
3 |
Correct |
5 ms |
984 KB |
Output is correct |
4 |
Correct |
5 ms |
984 KB |
Output is correct |
5 |
Correct |
36 ms |
6548 KB |
Output is correct |
6 |
Correct |
14 ms |
2008 KB |
Output is correct |
7 |
Correct |
10 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
204 ms |
20804 KB |
Output is correct |
2 |
Correct |
16 ms |
1880 KB |
Output is correct |
3 |
Correct |
5 ms |
856 KB |
Output is correct |
4 |
Correct |
214 ms |
20864 KB |
Output is correct |
5 |
Correct |
48 ms |
10592 KB |
Output is correct |
6 |
Correct |
10 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |