#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int mod = 1e9 + 7;
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;
ll m;
cin>>n>>m;
ll a[n];
for(int i = 0; i < n; i++)cin>>a[i];
// [0, n / 2 - 1], [n / 2, n - 1]
vector<ll>v;
for(int mask = 0; mask < (1 << ((n+1)>>1)); mask++){
ll sum = 0;
for(int i = 0; i < (n+1)/2; i++){
if(mask & (1 << i))
sum += a[i + (n >> 1)];
}
v.push_back(sum);
}
sort(v.begin(), v.end());
ll ans = 0;
for(int mask = 0; mask < (1 << (n >> 1)); mask++){
ll sum = 0;
for(int i = 0; i < (n >> 1); i++){
if(mask & (1 << i))
sum += a[i];
}
ans += upper_bound(v.begin(), v.end(), m - sum) - v.begin();
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
324 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 |
340 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 |
316 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 |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
1368 KB |
Output is correct |
2 |
Correct |
93 ms |
2412 KB |
Output is correct |
3 |
Correct |
418 ms |
8624 KB |
Output is correct |
4 |
Correct |
85 ms |
2444 KB |
Output is correct |
5 |
Correct |
17 ms |
856 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 |
38 ms |
1524 KB |
Output is correct |
2 |
Correct |
27 ms |
1492 KB |
Output is correct |
3 |
Correct |
169 ms |
4548 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
6 ms |
600 KB |
Output is correct |
6 |
Correct |
13 ms |
884 KB |
Output is correct |
7 |
Correct |
13 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
2512 KB |
Output is correct |
2 |
Correct |
131 ms |
4536 KB |
Output is correct |
3 |
Correct |
123 ms |
4524 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
78 ms |
4640 KB |
Output is correct |
6 |
Correct |
221 ms |
8572 KB |
Output is correct |
7 |
Correct |
105 ms |
4548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
262 ms |
8564 KB |
Output is correct |
2 |
Correct |
26 ms |
1492 KB |
Output is correct |
3 |
Correct |
9 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
7 ms |
600 KB |
Output is correct |
6 |
Correct |
195 ms |
8648 KB |
Output is correct |
7 |
Correct |
13 ms |
984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1476 KB |
Output is correct |
2 |
Correct |
81 ms |
2512 KB |
Output is correct |
3 |
Correct |
8 ms |
600 KB |
Output is correct |
4 |
Correct |
8 ms |
600 KB |
Output is correct |
5 |
Correct |
93 ms |
4516 KB |
Output is correct |
6 |
Correct |
21 ms |
1492 KB |
Output is correct |
7 |
Correct |
232 ms |
8608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
322 ms |
8644 KB |
Output is correct |
2 |
Correct |
28 ms |
1492 KB |
Output is correct |
3 |
Correct |
9 ms |
600 KB |
Output is correct |
4 |
Correct |
429 ms |
8616 KB |
Output is correct |
5 |
Correct |
118 ms |
4556 KB |
Output is correct |
6 |
Correct |
15 ms |
984 KB |
Output is correct |
7 |
Correct |
26 ms |
1476 KB |
Output is correct |