#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define inf 1e18
const int N=45;
int arr[N];
signed main(){
int n,x;
cin>>n>>x;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
vector<int>v,vc;
for(int i=1;i<=n/2;i++){
v.pb(arr[i]);
}
for(int i=n/2+1;i<=n;i++){
vc.pb(arr[i]);
}
vector<int>mp1,mp2;
int m=v.size();
for(int i=0;i<(1<<m);i++){
int s=0;
for(int j=0;j<m;j++){
if(i & (1<<j)){
s+=v[j];
}
}
mp1.pb(s);
}
m=vc.size();
for(int i=0;i<(1<<m);i++){
int s=0;
for(int j=0;j<m;j++){
if(i & (1<<j)){
s+=vc[j];
}
}
mp2.pb(s);
}
sort(mp2.begin(),mp2.end());
sort(mp1.begin(),mp1.end());
int cnt=0;
for(auto a:mp1){
auto up=upper_bound(mp2.begin(),mp2.end(),x-a);
cnt+=up-mp2.begin();
}
cout<<cnt;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
508 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 |
504 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 |
24 ms |
2112 KB |
Output is correct |
2 |
Correct |
74 ms |
6484 KB |
Output is correct |
3 |
Correct |
302 ms |
22952 KB |
Output is correct |
4 |
Correct |
73 ms |
6464 KB |
Output is correct |
5 |
Correct |
13 ms |
1480 KB |
Output is correct |
6 |
Correct |
9 ms |
1228 KB |
Output is correct |
7 |
Correct |
17 ms |
1648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
2756 KB |
Output is correct |
2 |
Correct |
26 ms |
2124 KB |
Output is correct |
3 |
Correct |
124 ms |
12596 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
7 ms |
972 KB |
Output is correct |
6 |
Correct |
17 ms |
1736 KB |
Output is correct |
7 |
Correct |
17 ms |
1480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
4680 KB |
Output is correct |
2 |
Correct |
112 ms |
8764 KB |
Output is correct |
3 |
Correct |
107 ms |
8772 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
75 ms |
8764 KB |
Output is correct |
6 |
Correct |
268 ms |
22952 KB |
Output is correct |
7 |
Correct |
102 ms |
8764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
220 ms |
14912 KB |
Output is correct |
2 |
Correct |
28 ms |
2124 KB |
Output is correct |
3 |
Correct |
10 ms |
972 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
7 ms |
972 KB |
Output is correct |
6 |
Correct |
212 ms |
14900 KB |
Output is correct |
7 |
Correct |
17 ms |
1480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
1868 KB |
Output is correct |
2 |
Correct |
74 ms |
6592 KB |
Output is correct |
3 |
Correct |
10 ms |
972 KB |
Output is correct |
4 |
Correct |
10 ms |
972 KB |
Output is correct |
5 |
Correct |
82 ms |
8772 KB |
Output is correct |
6 |
Correct |
28 ms |
1868 KB |
Output is correct |
7 |
Correct |
294 ms |
22952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
310 ms |
22952 KB |
Output is correct |
2 |
Correct |
30 ms |
2136 KB |
Output is correct |
3 |
Correct |
10 ms |
972 KB |
Output is correct |
4 |
Correct |
306 ms |
22952 KB |
Output is correct |
5 |
Correct |
105 ms |
12604 KB |
Output is correct |
6 |
Correct |
17 ms |
1480 KB |
Output is correct |
7 |
Correct |
34 ms |
3012 KB |
Output is correct |