#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 1e7 + 2;
const int inf = 1e9;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
ll m;
cin >> n >> m;
vector<ll> a, b;
for (int i = 0; i < n; i++) {
ll x; cin >> x;
if (i < n / 2) a.push_back(x);
else b.push_back(x);
}
vector<ll> v;
int sza = a.size();
for (int mask = 0; mask < (1 << sza); mask++) {
ll sum = 0;
for (int i = 0; i < sza; i++) {
if ((1 << i) & mask) sum += a[i];
}
v.push_back(sum);
}
sort(v.begin(), v.end());
int szb = b.size();
ll ans = 0;
for (int mask = 0; mask < (1 << szb); mask++) {
ll sum = 0;
for (int i = 0; i < szb; i++) {
if ((1 << i) & mask) sum += b[i];
}
ans += (int)(upper_bound(v.begin(), v.end(), m - sum) - v.begin());
}
cout << ans << en;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
856 KB |
Output is correct |
2 |
Correct |
89 ms |
2620 KB |
Output is correct |
3 |
Correct |
438 ms |
8612 KB |
Output is correct |
4 |
Correct |
89 ms |
2400 KB |
Output is correct |
5 |
Correct |
14 ms |
984 KB |
Output is correct |
6 |
Correct |
7 ms |
708 KB |
Output is correct |
7 |
Correct |
13 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
1492 KB |
Output is correct |
2 |
Correct |
33 ms |
984 KB |
Output is correct |
3 |
Correct |
174 ms |
4556 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
7 ms |
644 KB |
Output is correct |
6 |
Correct |
13 ms |
856 KB |
Output is correct |
7 |
Correct |
13 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
67 ms |
1472 KB |
Output is correct |
2 |
Correct |
147 ms |
2512 KB |
Output is correct |
3 |
Correct |
149 ms |
2512 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
82 ms |
2512 KB |
Output is correct |
6 |
Correct |
241 ms |
8640 KB |
Output is correct |
7 |
Correct |
76 ms |
2512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
321 ms |
4556 KB |
Output is correct |
2 |
Correct |
30 ms |
964 KB |
Output is correct |
3 |
Correct |
9 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
9 ms |
600 KB |
Output is correct |
6 |
Correct |
150 ms |
4508 KB |
Output is correct |
7 |
Correct |
15 ms |
984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
856 KB |
Output is correct |
2 |
Correct |
86 ms |
2516 KB |
Output is correct |
3 |
Correct |
8 ms |
600 KB |
Output is correct |
4 |
Correct |
9 ms |
728 KB |
Output is correct |
5 |
Correct |
100 ms |
2512 KB |
Output is correct |
6 |
Correct |
18 ms |
856 KB |
Output is correct |
7 |
Correct |
233 ms |
8656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
355 ms |
8656 KB |
Output is correct |
2 |
Correct |
32 ms |
984 KB |
Output is correct |
3 |
Correct |
10 ms |
600 KB |
Output is correct |
4 |
Correct |
433 ms |
8628 KB |
Output is correct |
5 |
Correct |
120 ms |
4496 KB |
Output is correct |
6 |
Correct |
15 ms |
960 KB |
Output is correct |
7 |
Correct |
29 ms |
1492 KB |
Output is correct |