#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define pb push_back
int main() {
int n; ll m; cin >> n >> m;
vector<ll> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
}
int mid = (n-1) / 2;
vector<ll> p1;
for (int i = 0; i < (1 << (mid+1)); ++i) {
ll sum = 0;
int x = i;
for (int j = 0; j <= mid; ++j) {
if (x % 2 == 1) sum += v[j];
x /= 2;
}
if (sum <= m) p1.pb(sum);
}
sort(p1.begin(), p1.end());
ll ans = 0;
for (int i = 0; i < (1 << (n - mid - 1)); ++i) {
ll sum = 0;
int x = i;
for (int j = mid + 1; j < n; ++j) {
if (x % 2 == 1) sum += v[j];
x /= 2;
}
if (sum > m) continue;
int k = upper_bound(p1.begin(), p1.end(), m - sum) - p1.begin();
ans += 1ll * k;
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
204 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 |
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 |
204 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 |
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 |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
1416 KB |
Output is correct |
2 |
Correct |
103 ms |
2496 KB |
Output is correct |
3 |
Correct |
481 ms |
8620 KB |
Output is correct |
4 |
Correct |
101 ms |
2368 KB |
Output is correct |
5 |
Correct |
16 ms |
840 KB |
Output is correct |
6 |
Correct |
7 ms |
672 KB |
Output is correct |
7 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
1424 KB |
Output is correct |
2 |
Correct |
33 ms |
1348 KB |
Output is correct |
3 |
Correct |
201 ms |
4548 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
8 ms |
620 KB |
Output is correct |
6 |
Correct |
15 ms |
840 KB |
Output is correct |
7 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
2484 KB |
Output is correct |
2 |
Correct |
160 ms |
4528 KB |
Output is correct |
3 |
Correct |
155 ms |
4540 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
91 ms |
4532 KB |
Output is correct |
6 |
Correct |
249 ms |
8604 KB |
Output is correct |
7 |
Correct |
47 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
308 ms |
8592 KB |
Output is correct |
2 |
Correct |
32 ms |
1436 KB |
Output is correct |
3 |
Correct |
10 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
8 ms |
588 KB |
Output is correct |
6 |
Correct |
216 ms |
8528 KB |
Output is correct |
7 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
1348 KB |
Output is correct |
2 |
Correct |
98 ms |
2452 KB |
Output is correct |
3 |
Correct |
10 ms |
588 KB |
Output is correct |
4 |
Correct |
10 ms |
588 KB |
Output is correct |
5 |
Correct |
98 ms |
4448 KB |
Output is correct |
6 |
Correct |
25 ms |
1348 KB |
Output is correct |
7 |
Correct |
130 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
414 ms |
8544 KB |
Output is correct |
2 |
Correct |
35 ms |
1404 KB |
Output is correct |
3 |
Correct |
10 ms |
588 KB |
Output is correct |
4 |
Correct |
486 ms |
8516 KB |
Output is correct |
5 |
Correct |
141 ms |
4540 KB |
Output is correct |
6 |
Correct |
15 ms |
840 KB |
Output is correct |
7 |
Correct |
16 ms |
296 KB |
Output is correct |