/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 40;
int N; ll M;
ll A[N_MAX + 2];
vector <ll> getAll (int l, int r) {
vector <ll> ret;
for (int mask = 0; mask < (1 << (r - l + 1)); mask++) {
ll sum = 0;
for (int i = 0; i < r - l + 1; i++) {
if ((mask >> i) & 1) {
sum += A[l + i];
}
}
ret.push_back(sum);
}
return ret;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N >> M;
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
vector <ll> lv = getAll(1, N / 2);
vector <ll> rv = getAll(N / 2 + 1, N);
sort(lv.begin(), lv.end());
sort(rv.begin(), rv.end());
ll answer = 0;
for (int l = 0, r = (int) rv.size() - 1; l < (int) lv.size(); l++) {
while (r >= 0 && lv[l] + rv[r] > M) {
r--;
}
answer += r - 0 + 1;
}
cout << answer << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
1908 KB |
Output is correct |
2 |
Correct |
76 ms |
5316 KB |
Output is correct |
3 |
Correct |
321 ms |
20772 KB |
Output is correct |
4 |
Correct |
79 ms |
5368 KB |
Output is correct |
5 |
Correct |
13 ms |
1612 KB |
Output is correct |
6 |
Correct |
9 ms |
976 KB |
Output is correct |
7 |
Correct |
16 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
2868 KB |
Output is correct |
2 |
Correct |
33 ms |
1972 KB |
Output is correct |
3 |
Correct |
133 ms |
10540 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
7 ms |
976 KB |
Output is correct |
6 |
Correct |
17 ms |
1612 KB |
Output is correct |
7 |
Correct |
17 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
3504 KB |
Output is correct |
2 |
Correct |
119 ms |
6616 KB |
Output is correct |
3 |
Correct |
130 ms |
6592 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
73 ms |
6512 KB |
Output is correct |
6 |
Correct |
248 ms |
20772 KB |
Output is correct |
7 |
Correct |
111 ms |
6592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
254 ms |
12768 KB |
Output is correct |
2 |
Correct |
27 ms |
2000 KB |
Output is correct |
3 |
Correct |
9 ms |
976 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
7 ms |
976 KB |
Output is correct |
6 |
Correct |
235 ms |
12724 KB |
Output is correct |
7 |
Correct |
19 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
1996 KB |
Output is correct |
2 |
Correct |
74 ms |
5444 KB |
Output is correct |
3 |
Correct |
9 ms |
976 KB |
Output is correct |
4 |
Correct |
8 ms |
976 KB |
Output is correct |
5 |
Correct |
86 ms |
6584 KB |
Output is correct |
6 |
Correct |
27 ms |
1984 KB |
Output is correct |
7 |
Correct |
309 ms |
20888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
349 ms |
20772 KB |
Output is correct |
2 |
Correct |
28 ms |
1980 KB |
Output is correct |
3 |
Correct |
9 ms |
976 KB |
Output is correct |
4 |
Correct |
342 ms |
20820 KB |
Output is correct |
5 |
Correct |
109 ms |
10484 KB |
Output is correct |
6 |
Correct |
16 ms |
1484 KB |
Output is correct |
7 |
Correct |
34 ms |
2888 KB |
Output is correct |