#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
ll pr[41];
ll solve(ll curr,ll pos) {
if (curr == 0) {
return 1;
}
ll c=1;
for (int i=pos+1;i<n;i++) {
if (curr-pr[i] >= 0) {
c+=solve(curr-pr[i],i);
} else {
return c;
}
}
return c;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
cin >> n >> m;
for (int i=0;i<n;i++) {
cin >> pr[i];
}
sort(pr,pr+n);
int left=0,right=n-1,mid;
while (left < right) {
mid =(left+right)/2;
if (pr[mid] < m) {
left = mid+1;
} else {
right = mid;
}
}
n = left;
cout << solve(m,-1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1032 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1004 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1035 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1033 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |