#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int>vec;
int a[50],n,m,ans;
void calcLeft(int i,int sum) {
if (i > n / 2) {
if (sum <= m) vec.push_back(sum);
return;
}
calcLeft(i + 1,sum);
calcLeft(i + 1,sum + a[i]);
}
int tknp(int l,int r,int x) {
int ans = 0;
while (l <= r) {
int mid = (l + r) / 2;
if (vec[mid] <= x) ans = max(ans,mid + 1),l = mid + 1;
else r = mid - 1;
}
return ans;
}
void calcRight(int i,int sum) {
if (i > n) {
if (sum <= m) ans += tknp(0,vec.size() - 1,m - sum);
return;
}
calcRight(i + 1,sum);
calcRight(i + 1,sum + a[i]);
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
calcLeft(1,0);
sort(vec.begin(),vec.end());
calcRight(n / 2 + 1,0);
cout << ans << "\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 |
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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
992 KB |
Output is correct |
2 |
Correct |
63 ms |
2520 KB |
Output is correct |
3 |
Correct |
249 ms |
9676 KB |
Output is correct |
4 |
Correct |
59 ms |
2520 KB |
Output is correct |
5 |
Correct |
6 ms |
992 KB |
Output is correct |
6 |
Correct |
4 ms |
992 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
1612 KB |
Output is correct |
2 |
Correct |
21 ms |
1244 KB |
Output is correct |
3 |
Correct |
122 ms |
5588 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
732 KB |
Output is correct |
6 |
Correct |
7 ms |
988 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
1500 KB |
Output is correct |
2 |
Correct |
104 ms |
2520 KB |
Output is correct |
3 |
Correct |
91 ms |
2520 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
26 ms |
2520 KB |
Output is correct |
6 |
Correct |
107 ms |
9660 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
6612 KB |
Output is correct |
2 |
Correct |
19 ms |
1244 KB |
Output is correct |
3 |
Correct |
6 ms |
736 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
736 KB |
Output is correct |
6 |
Correct |
80 ms |
4564 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
992 KB |
Output is correct |
2 |
Correct |
61 ms |
2520 KB |
Output is correct |
3 |
Correct |
5 ms |
736 KB |
Output is correct |
4 |
Correct |
5 ms |
736 KB |
Output is correct |
5 |
Correct |
38 ms |
2520 KB |
Output is correct |
6 |
Correct |
9 ms |
992 KB |
Output is correct |
7 |
Correct |
8 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
9168 KB |
Output is correct |
2 |
Correct |
20 ms |
992 KB |
Output is correct |
3 |
Correct |
6 ms |
732 KB |
Output is correct |
4 |
Correct |
288 ms |
9164 KB |
Output is correct |
5 |
Correct |
42 ms |
6352 KB |
Output is correct |
6 |
Correct |
7 ms |
988 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |