#include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N; ll M;
cin >> N >> M;
int n = N / 2, m = N - n;
vector<ll> s1(n), s2(m);
for (int i = 0; i < n; i++)
cin >> s1[i];
for (int j = 0; j < m; j++)
cin >>s2[j];
vector<ll> all_sums;
for (int i = 0; i < (1 << n); i++) {
ll s = 0;
for (int j = 0; j < n; j++)
if ((i & (1 << j)) != 0)
s += s1[j];
all_sums.push_back(s);
}
sort(all(all_sums));
ll out = 0;
for (int i = 0; i < (1 << m); i++) {
ll s = 0;
for (int j = 0; j < m; j++)
if ((i & (1 << j)) != 0)
s += s2[j];
out += upper_bound(all(all_sums), M - s) - all_sums.begin();
}
cout << out << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
992 KB |
Output is correct |
2 |
Correct |
85 ms |
2520 KB |
Output is correct |
3 |
Correct |
379 ms |
9924 KB |
Output is correct |
4 |
Correct |
85 ms |
2520 KB |
Output is correct |
5 |
Correct |
13 ms |
988 KB |
Output is correct |
6 |
Correct |
6 ms |
736 KB |
Output is correct |
7 |
Correct |
12 ms |
992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1500 KB |
Output is correct |
2 |
Correct |
27 ms |
988 KB |
Output is correct |
3 |
Correct |
162 ms |
6672 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
736 KB |
Output is correct |
6 |
Correct |
12 ms |
992 KB |
Output is correct |
7 |
Correct |
12 ms |
992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
1500 KB |
Output is correct |
2 |
Correct |
133 ms |
2520 KB |
Output is correct |
3 |
Correct |
134 ms |
2540 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
75 ms |
2452 KB |
Output is correct |
6 |
Correct |
211 ms |
10760 KB |
Output is correct |
7 |
Correct |
71 ms |
2516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
284 ms |
5332 KB |
Output is correct |
2 |
Correct |
26 ms |
992 KB |
Output is correct |
3 |
Correct |
8 ms |
736 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
736 KB |
Output is correct |
6 |
Correct |
156 ms |
4672 KB |
Output is correct |
7 |
Correct |
13 ms |
992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
992 KB |
Output is correct |
2 |
Correct |
78 ms |
2520 KB |
Output is correct |
3 |
Correct |
7 ms |
736 KB |
Output is correct |
4 |
Correct |
8 ms |
736 KB |
Output is correct |
5 |
Correct |
92 ms |
2496 KB |
Output is correct |
6 |
Correct |
17 ms |
992 KB |
Output is correct |
7 |
Correct |
218 ms |
9948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
341 ms |
9924 KB |
Output is correct |
2 |
Correct |
27 ms |
992 KB |
Output is correct |
3 |
Correct |
8 ms |
736 KB |
Output is correct |
4 |
Correct |
433 ms |
9580 KB |
Output is correct |
5 |
Correct |
111 ms |
6608 KB |
Output is correct |
6 |
Correct |
12 ms |
992 KB |
Output is correct |
7 |
Correct |
25 ms |
1504 KB |
Output is correct |