#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int n;
ll m, ar[41], res = 0;
vector<ll> pos[2];
void rs(int s, int l, ll k, int id)
{
if (s < l)
{
rs(s + 1, l, k, id);
rs(s + 1, l, k + ar[s], id);
}
else {pos[id].push_back(k);}
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> ar[i];
rs(0, n / 2, 0, 0);
rs(n / 2, n, 0, 1);
sort(pos[0].begin(), pos[0].end());
sort(pos[1].begin(), pos[1].end());
ll R = pos[1].size() - 1;
for (int i = 0; i < pos[0].size(); i++)
{
while (R >= 0 && pos[0][i] + pos[1][R] > m) {R--;}
res += (R + 1);
}
cout << res << "\n";
return 0;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < pos[0].size(); i++)
~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2040 KB |
Output is correct |
2 |
Correct |
58 ms |
5488 KB |
Output is correct |
3 |
Correct |
238 ms |
20828 KB |
Output is correct |
4 |
Correct |
56 ms |
5488 KB |
Output is correct |
5 |
Correct |
8 ms |
1656 KB |
Output is correct |
6 |
Correct |
6 ms |
1020 KB |
Output is correct |
7 |
Correct |
14 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
2932 KB |
Output is correct |
2 |
Correct |
20 ms |
2040 KB |
Output is correct |
3 |
Correct |
90 ms |
10604 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
1020 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
12 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
3572 KB |
Output is correct |
2 |
Correct |
85 ms |
6640 KB |
Output is correct |
3 |
Correct |
84 ms |
6640 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
42 ms |
6640 KB |
Output is correct |
6 |
Correct |
188 ms |
20828 KB |
Output is correct |
7 |
Correct |
80 ms |
6640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
12772 KB |
Output is correct |
2 |
Correct |
20 ms |
2040 KB |
Output is correct |
3 |
Correct |
6 ms |
1020 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
1020 KB |
Output is correct |
6 |
Correct |
172 ms |
12780 KB |
Output is correct |
7 |
Correct |
13 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
2040 KB |
Output is correct |
2 |
Correct |
57 ms |
5488 KB |
Output is correct |
3 |
Correct |
6 ms |
1020 KB |
Output is correct |
4 |
Correct |
6 ms |
1020 KB |
Output is correct |
5 |
Correct |
48 ms |
6640 KB |
Output is correct |
6 |
Correct |
20 ms |
2040 KB |
Output is correct |
7 |
Correct |
242 ms |
20840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
20840 KB |
Output is correct |
2 |
Correct |
21 ms |
2040 KB |
Output is correct |
3 |
Correct |
6 ms |
1020 KB |
Output is correct |
4 |
Correct |
241 ms |
20824 KB |
Output is correct |
5 |
Correct |
61 ms |
10604 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
26 ms |
2932 KB |
Output is correct |