#include <bits/stdc++.h>
using namespace std;
long long n,m,total;
long long arr[41];
int main() {
cin>>n>>m;
for (int i=0;i<n;i++) cin>>arr[i];
vector<long long> sums;
int fh=n/2;
for (int i=0;i<(1<<fh);i++){
long long sum=0;
for (int j=0;j<fh;j++){
if (i&(1<<j)) sum+=arr[j];
}
sums.push_back(sum);
}
sort(sums.begin(),sums.end());
int sh=n-fh;
for (int i=0;i<(1<<sh);i++){
long long sum=0;
for (int j=0;j<sh;j++){
if (i&(1<<j)) sum+=arr[fh+j];
}
sum=m-sum;
int countt=upper_bound(sums.begin(),sums.end(),sum)-sums.begin();
total+=countt;
}
cout<<total;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
1012 KB |
Output is correct |
2 |
Correct |
119 ms |
2536 KB |
Output is correct |
3 |
Correct |
530 ms |
8668 KB |
Output is correct |
4 |
Correct |
116 ms |
2540 KB |
Output is correct |
5 |
Correct |
19 ms |
1008 KB |
Output is correct |
6 |
Correct |
10 ms |
780 KB |
Output is correct |
7 |
Correct |
17 ms |
1012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
1520 KB |
Output is correct |
2 |
Correct |
39 ms |
1012 KB |
Output is correct |
3 |
Correct |
227 ms |
4580 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
10 ms |
760 KB |
Output is correct |
6 |
Correct |
19 ms |
1012 KB |
Output is correct |
7 |
Correct |
17 ms |
1012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
1520 KB |
Output is correct |
2 |
Correct |
196 ms |
2536 KB |
Output is correct |
3 |
Correct |
185 ms |
2468 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
99 ms |
2660 KB |
Output is correct |
6 |
Correct |
305 ms |
8668 KB |
Output is correct |
7 |
Correct |
93 ms |
2540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
397 ms |
4580 KB |
Output is correct |
2 |
Correct |
33 ms |
1012 KB |
Output is correct |
3 |
Correct |
13 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
10 ms |
760 KB |
Output is correct |
6 |
Correct |
217 ms |
4580 KB |
Output is correct |
7 |
Correct |
17 ms |
1012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
1012 KB |
Output is correct |
2 |
Correct |
116 ms |
2540 KB |
Output is correct |
3 |
Correct |
12 ms |
760 KB |
Output is correct |
4 |
Correct |
12 ms |
760 KB |
Output is correct |
5 |
Correct |
130 ms |
2540 KB |
Output is correct |
6 |
Correct |
26 ms |
888 KB |
Output is correct |
7 |
Correct |
288 ms |
8640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
458 ms |
8752 KB |
Output is correct |
2 |
Correct |
40 ms |
1008 KB |
Output is correct |
3 |
Correct |
13 ms |
760 KB |
Output is correct |
4 |
Correct |
557 ms |
8752 KB |
Output is correct |
5 |
Correct |
149 ms |
4580 KB |
Output is correct |
6 |
Correct |
19 ms |
1012 KB |
Output is correct |
7 |
Correct |
34 ms |
1496 KB |
Output is correct |