#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll=long long;
ll a[41];
vector<ll>v;
int n,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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
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 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
980 KB |
Output is correct |
2 |
Correct |
70 ms |
3532 KB |
Output is correct |
3 |
Correct |
317 ms |
10692 KB |
Output is correct |
4 |
Correct |
64 ms |
3532 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
7 |
Correct |
6 ms |
1148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
1488 KB |
Output is correct |
2 |
Correct |
18 ms |
980 KB |
Output is correct |
3 |
Correct |
137 ms |
6600 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
724 KB |
Output is correct |
6 |
Correct |
7 ms |
980 KB |
Output is correct |
7 |
Correct |
6 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
1488 KB |
Output is correct |
2 |
Correct |
106 ms |
3532 KB |
Output is correct |
3 |
Correct |
107 ms |
3532 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
24 ms |
3764 KB |
Output is correct |
6 |
Correct |
85 ms |
10692 KB |
Output is correct |
7 |
Correct |
24 ms |
3532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
6600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
10692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |