#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> A, B;
int n;
ll m;
ll price_a[20], price_b[20];
int main(){
cin >> n >> m;
for(int i = 0; i < n/2; i++){
cin >> price_a[i];
}
for(int i = 0; i < (n+1)/2; i++){
cin >> price_b[i];
}
for(int b = 0; b < (1 << n/2); b++){
ll subset_sum = 0;
for(int i = 0; i < n/2; i++){
if(b >> i & 1){
subset_sum += price_a[i];
}
}
A.push_back(subset_sum);
}
for(int b = 0; b < (1 << (n+1)/2); b++){
ll subset_sum = 0;
for(int i = 0; i < (n+1)/2; i++){
if(b >> i & 1){
subset_sum += price_b[i];
}
}
B.push_back(subset_sum);
}
sort(A.begin(),A.end());
ll ans = 0;
for(ll &b : B){
ans += upper_bound(A.begin(),A.end(),m-b) - A.begin();
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
412 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
3 ms |
444 KB |
Output is correct |
6 |
Correct |
2 ms |
444 KB |
Output is correct |
7 |
Correct |
3 ms |
444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
520 KB |
Output is correct |
2 |
Correct |
3 ms |
520 KB |
Output is correct |
3 |
Correct |
3 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
528 KB |
Output is correct |
5 |
Correct |
2 ms |
708 KB |
Output is correct |
6 |
Correct |
3 ms |
708 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
720 KB |
Output is correct |
2 |
Correct |
2 ms |
720 KB |
Output is correct |
3 |
Correct |
3 ms |
720 KB |
Output is correct |
4 |
Correct |
2 ms |
720 KB |
Output is correct |
5 |
Correct |
4 ms |
720 KB |
Output is correct |
6 |
Correct |
3 ms |
720 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2316 KB |
Output is correct |
2 |
Correct |
133 ms |
5760 KB |
Output is correct |
3 |
Correct |
581 ms |
21100 KB |
Output is correct |
4 |
Correct |
125 ms |
21100 KB |
Output is correct |
5 |
Correct |
20 ms |
21100 KB |
Output is correct |
6 |
Correct |
10 ms |
21100 KB |
Output is correct |
7 |
Correct |
19 ms |
21100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
21100 KB |
Output is correct |
2 |
Correct |
52 ms |
21100 KB |
Output is correct |
3 |
Correct |
267 ms |
21100 KB |
Output is correct |
4 |
Correct |
3 ms |
21100 KB |
Output is correct |
5 |
Correct |
10 ms |
21100 KB |
Output is correct |
6 |
Correct |
19 ms |
21100 KB |
Output is correct |
7 |
Correct |
19 ms |
21100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
21100 KB |
Output is correct |
2 |
Correct |
209 ms |
21100 KB |
Output is correct |
3 |
Correct |
195 ms |
21100 KB |
Output is correct |
4 |
Correct |
2 ms |
21100 KB |
Output is correct |
5 |
Correct |
96 ms |
21100 KB |
Output is correct |
6 |
Correct |
315 ms |
21100 KB |
Output is correct |
7 |
Correct |
105 ms |
21100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
440 ms |
21100 KB |
Output is correct |
2 |
Correct |
44 ms |
21100 KB |
Output is correct |
3 |
Correct |
15 ms |
21100 KB |
Output is correct |
4 |
Correct |
2 ms |
21100 KB |
Output is correct |
5 |
Correct |
12 ms |
21100 KB |
Output is correct |
6 |
Correct |
249 ms |
21100 KB |
Output is correct |
7 |
Correct |
19 ms |
21100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
21100 KB |
Output is correct |
2 |
Correct |
124 ms |
21100 KB |
Output is correct |
3 |
Correct |
13 ms |
21100 KB |
Output is correct |
4 |
Correct |
13 ms |
21100 KB |
Output is correct |
5 |
Correct |
118 ms |
21100 KB |
Output is correct |
6 |
Correct |
29 ms |
21100 KB |
Output is correct |
7 |
Correct |
344 ms |
21168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
502 ms |
21208 KB |
Output is correct |
2 |
Correct |
44 ms |
21208 KB |
Output is correct |
3 |
Correct |
13 ms |
21208 KB |
Output is correct |
4 |
Correct |
587 ms |
21272 KB |
Output is correct |
5 |
Correct |
138 ms |
21272 KB |
Output is correct |
6 |
Correct |
20 ms |
21272 KB |
Output is correct |
7 |
Correct |
42 ms |
21272 KB |
Output is correct |