#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> A, B;
int n;
ll m;
int 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 |
3 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 |
540 KB |
Output is correct |
3 |
Correct |
2 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
2288 KB |
Output is correct |
2 |
Correct |
126 ms |
5720 KB |
Output is correct |
3 |
Correct |
565 ms |
21120 KB |
Output is correct |
4 |
Correct |
132 ms |
21120 KB |
Output is correct |
5 |
Correct |
18 ms |
21120 KB |
Output is correct |
6 |
Correct |
10 ms |
21120 KB |
Output is correct |
7 |
Correct |
18 ms |
21120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
21120 KB |
Output is correct |
2 |
Correct |
45 ms |
21120 KB |
Output is correct |
3 |
Correct |
245 ms |
21120 KB |
Output is correct |
4 |
Correct |
2 ms |
21120 KB |
Output is correct |
5 |
Correct |
9 ms |
21120 KB |
Output is correct |
6 |
Correct |
20 ms |
21120 KB |
Output is correct |
7 |
Correct |
18 ms |
21120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
21120 KB |
Output is correct |
2 |
Correct |
203 ms |
21120 KB |
Output is correct |
3 |
Correct |
197 ms |
21120 KB |
Output is correct |
4 |
Correct |
2 ms |
21120 KB |
Output is correct |
5 |
Correct |
97 ms |
21120 KB |
Output is correct |
6 |
Correct |
313 ms |
21120 KB |
Output is correct |
7 |
Correct |
99 ms |
21120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
202 ms |
21120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
21120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
281 ms |
21120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |