#include<bits/stdc++.h>
using namespace std;
long long n,n1,n2,m,a[21],b[21];
vector<int>v1,v2;
int main(){
cin>>n>>m;
n1=n/2;
n2=n-n/2;
for(int i=1;i<=n1;i++){
cin>>a[i];
}
for(int i=1;i<=n2;i++){
cin>>b[i];
}
for(int i=0;i<(1<<n1);i++){
long long sum=0;
for(int j=0;j<n1;j++){
if(i&(1<<j)){
sum+=a[j+1];
}
}
v1.push_back(sum);
}
for(int i=0;i<(1<<n2);i++){
long long sum=0;
for(int j=0;j<n2;j++){
if(i&(1<<j)){
sum+=b[j+1];
}
}
v2.push_back(sum);
}
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
long long ans=0;
for(long long i:v1){
ans+=upper_bound(v2.begin(),v2.end(),m-i)-v2.begin();
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1116 KB |
Output is correct |
2 |
Correct |
57 ms |
2764 KB |
Output is correct |
3 |
Correct |
244 ms |
11704 KB |
Output is correct |
4 |
Correct |
58 ms |
2768 KB |
Output is correct |
5 |
Correct |
11 ms |
984 KB |
Output is correct |
6 |
Correct |
7 ms |
604 KB |
Output is correct |
7 |
Correct |
13 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
1492 KB |
Output is correct |
2 |
Correct |
21 ms |
1116 KB |
Output is correct |
3 |
Correct |
116 ms |
5444 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
604 KB |
Output is correct |
6 |
Correct |
13 ms |
984 KB |
Output is correct |
7 |
Correct |
13 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
1880 KB |
Output is correct |
2 |
Correct |
84 ms |
3400 KB |
Output is correct |
3 |
Correct |
84 ms |
3400 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
55 ms |
3604 KB |
Output is correct |
6 |
Correct |
219 ms |
11192 KB |
Output is correct |
7 |
Correct |
82 ms |
3668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
176 ms |
8000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
239 ms |
11196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |