//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n; cin >> n;
ll m, r = 0; cin >> m;
vector<ll> A(n), X;
for(int i = 0; i < n; i++) cin >> A[i];
int a = n / 2;
for(int msk = 0; msk < (1 << a); msk++) {
ll s = 0;
for(int i = 0; i < a; i++)
if(msk & (1 << i))
s += A[i];
if(s <= m) X.push_back(s);
}
sort(X.begin(), X.end());
for(int msk = 0; msk < (1 << (n - a)); msk++) {
ll s = 0;
for(int i = 0; i < n - a; i++)
if(msk & (1 << i))
s += A[a + i];
r += upper_bound(X.begin(), X.end(), m - s) - X.begin();
}
cout << r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
1012 KB |
Output is correct |
2 |
Correct |
112 ms |
2572 KB |
Output is correct |
3 |
Correct |
544 ms |
8668 KB |
Output is correct |
4 |
Correct |
119 ms |
2540 KB |
Output is correct |
5 |
Correct |
21 ms |
1012 KB |
Output is correct |
6 |
Correct |
14 ms |
888 KB |
Output is correct |
7 |
Correct |
13 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
1524 KB |
Output is correct |
2 |
Correct |
44 ms |
988 KB |
Output is correct |
3 |
Correct |
215 ms |
4628 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
13 ms |
760 KB |
Output is correct |
6 |
Correct |
20 ms |
1012 KB |
Output is correct |
7 |
Correct |
13 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
1520 KB |
Output is correct |
2 |
Correct |
198 ms |
2536 KB |
Output is correct |
3 |
Correct |
164 ms |
2536 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
100 ms |
2536 KB |
Output is correct |
6 |
Correct |
266 ms |
8612 KB |
Output is correct |
7 |
Correct |
55 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
350 ms |
4580 KB |
Output is correct |
2 |
Correct |
35 ms |
1012 KB |
Output is correct |
3 |
Correct |
15 ms |
760 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
13 ms |
760 KB |
Output is correct |
6 |
Correct |
202 ms |
4580 KB |
Output is correct |
7 |
Correct |
12 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
1012 KB |
Output is correct |
2 |
Correct |
102 ms |
2540 KB |
Output is correct |
3 |
Correct |
14 ms |
760 KB |
Output is correct |
4 |
Correct |
15 ms |
760 KB |
Output is correct |
5 |
Correct |
121 ms |
2540 KB |
Output is correct |
6 |
Correct |
25 ms |
1012 KB |
Output is correct |
7 |
Correct |
135 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
417 ms |
8672 KB |
Output is correct |
2 |
Correct |
39 ms |
1012 KB |
Output is correct |
3 |
Correct |
15 ms |
760 KB |
Output is correct |
4 |
Correct |
511 ms |
8668 KB |
Output is correct |
5 |
Correct |
156 ms |
4584 KB |
Output is correct |
6 |
Correct |
20 ms |
1012 KB |
Output is correct |
7 |
Correct |
20 ms |
256 KB |
Output is correct |