#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 45;
vector<int> v;
int n, m;
int a[maxn];
int mid;
int ans = 0;
void rec(int i, int sum)
{
if (i == mid)
{
v.push_back(sum);
return;
}
rec(i + 1, sum); rec(i + 1, sum + a[i]);
}
void rec2(int i, int sum)
{
if (i == mid - 1)
{
int idx = upper_bound(v.begin(), v.end(), m - sum) - v.begin();
// cout<<sum<<" "<<idx<<endl;
ans += idx;
return;
}
rec2(i - 1, sum); rec2(i - 1, sum + a[i]);
}
signed main()
{
cin>>n>>m;
for(int i=0; i<n; i++) cin>>a[i];
mid = (n + 1) / 2;
rec(0, 0);
sort(v.begin(), v.end());
// for(auto i : v) cout<<i<<" ";
// cout<<endl;
rec2(n - 1, 0);
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
508 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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
504 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1592 KB |
Output is correct |
2 |
Correct |
70 ms |
3780 KB |
Output is correct |
3 |
Correct |
304 ms |
10852 KB |
Output is correct |
4 |
Correct |
75 ms |
3524 KB |
Output is correct |
5 |
Correct |
5 ms |
972 KB |
Output is correct |
6 |
Correct |
4 ms |
716 KB |
Output is correct |
7 |
Correct |
6 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
1480 KB |
Output is correct |
2 |
Correct |
19 ms |
1604 KB |
Output is correct |
3 |
Correct |
127 ms |
6592 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
716 KB |
Output is correct |
6 |
Correct |
8 ms |
972 KB |
Output is correct |
7 |
Correct |
6 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
3524 KB |
Output is correct |
2 |
Correct |
92 ms |
6592 KB |
Output is correct |
3 |
Correct |
90 ms |
6592 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
31 ms |
6592 KB |
Output is correct |
6 |
Correct |
84 ms |
10684 KB |
Output is correct |
7 |
Correct |
52 ms |
6592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
10684 KB |
Output is correct |
2 |
Correct |
20 ms |
1480 KB |
Output is correct |
3 |
Correct |
8 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
716 KB |
Output is correct |
6 |
Correct |
98 ms |
10684 KB |
Output is correct |
7 |
Correct |
6 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1480 KB |
Output is correct |
2 |
Correct |
60 ms |
3464 KB |
Output is correct |
3 |
Correct |
5 ms |
716 KB |
Output is correct |
4 |
Correct |
6 ms |
716 KB |
Output is correct |
5 |
Correct |
33 ms |
6592 KB |
Output is correct |
6 |
Correct |
11 ms |
1480 KB |
Output is correct |
7 |
Correct |
105 ms |
10684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
243 ms |
10684 KB |
Output is correct |
2 |
Correct |
19 ms |
1480 KB |
Output is correct |
3 |
Correct |
6 ms |
716 KB |
Output is correct |
4 |
Correct |
336 ms |
10684 KB |
Output is correct |
5 |
Correct |
55 ms |
6592 KB |
Output is correct |
6 |
Correct |
7 ms |
972 KB |
Output is correct |
7 |
Correct |
13 ms |
1480 KB |
Output is correct |