#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
ll m;
cin >> n >> m;
vector<ll> l, r;
for(int i = 0; i < n; i++) {
ll x;
cin >> x;
if (i > n/2) {
r.push_back(x);
} else {
l.push_back(x);
}
}
vector<ll> ls, rs;
const int ln = l.size(), rn = r.size();
for(int mask = 0; mask < (1 << ln); mask++) {
ll sum = 0;
for(int i = 0; i < ln; i++) {
if (mask & (1 << i)) {
sum += l[i];
}
}
ls.push_back(sum);
}
for(int mask = 0; mask < (1 << rn); mask++) {
ll sum = 0;
for(int i = 0; i < rn; i++) {
if (mask & (1 << i)) {
sum += r[i];
}
}
rs.push_back(sum);
}
ll ans = 0;
sort(ls.begin(), ls.end());
sort(rs.begin(), rs.end());
for(ll i : ls) {
ll idx = upper_bound(rs.begin(), rs.end(), m - i) - rs.begin();
ans += idx;
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
396 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
2408 KB |
Output is correct |
2 |
Correct |
129 ms |
6492 KB |
Output is correct |
3 |
Correct |
538 ms |
25020 KB |
Output is correct |
4 |
Correct |
121 ms |
6496 KB |
Output is correct |
5 |
Correct |
21 ms |
1896 KB |
Output is correct |
6 |
Correct |
12 ms |
1132 KB |
Output is correct |
7 |
Correct |
27 ms |
1896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
3428 KB |
Output is correct |
2 |
Correct |
39 ms |
2408 KB |
Output is correct |
3 |
Correct |
231 ms |
12624 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
10 ms |
1132 KB |
Output is correct |
6 |
Correct |
26 ms |
1896 KB |
Output is correct |
7 |
Correct |
27 ms |
1896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
4580 KB |
Output is correct |
2 |
Correct |
158 ms |
8564 KB |
Output is correct |
3 |
Correct |
159 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
96 ms |
8692 KB |
Output is correct |
6 |
Correct |
458 ms |
25020 KB |
Output is correct |
7 |
Correct |
146 ms |
8668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
303 ms |
16848 KB |
Output is correct |
2 |
Correct |
38 ms |
2408 KB |
Output is correct |
3 |
Correct |
17 ms |
1132 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
10 ms |
1132 KB |
Output is correct |
6 |
Correct |
292 ms |
16720 KB |
Output is correct |
7 |
Correct |
27 ms |
1896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
2408 KB |
Output is correct |
2 |
Correct |
128 ms |
6788 KB |
Output is correct |
3 |
Correct |
14 ms |
1132 KB |
Output is correct |
4 |
Correct |
14 ms |
1132 KB |
Output is correct |
5 |
Correct |
119 ms |
8540 KB |
Output is correct |
6 |
Correct |
32 ms |
2408 KB |
Output is correct |
7 |
Correct |
534 ms |
25020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
523 ms |
25020 KB |
Output is correct |
2 |
Correct |
35 ms |
2408 KB |
Output is correct |
3 |
Correct |
15 ms |
1132 KB |
Output is correct |
4 |
Correct |
526 ms |
25100 KB |
Output is correct |
5 |
Correct |
171 ms |
12624 KB |
Output is correct |
6 |
Correct |
26 ms |
1896 KB |
Output is correct |
7 |
Correct |
57 ms |
3428 KB |
Output is correct |