#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 50;
map<ll,ll> memo[MAXN];
int n;
ll mm;
ll a[MAXN];
ll solve(int i,ll m)
{
if(m > mm)
return 0;
if(i == n)
return 1;
if(memo[i].find(m) != memo[i].end())
return memo[i][m];
ll &ret = memo[i][m];
ret = 0;
ret = solve(i + 1 , m + a[i]) + solve(i + 1 , m);
return ret;
}
int main()
{
cin >> n >> mm;
for(int i = 0 ; i < n ; i++)
cin >> a[i];
cout << solve(0,0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
5848 KB |
Output is correct |
2 |
Correct |
24 ms |
3388 KB |
Output is correct |
3 |
Correct |
37 ms |
4860 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Execution timed out |
1066 ms |
66028 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
863 ms |
54008 KB |
Output is correct |
2 |
Correct |
58 ms |
7288 KB |
Output is correct |
3 |
Correct |
26 ms |
3704 KB |
Output is correct |
4 |
Correct |
14 ms |
2040 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
75 ms |
8568 KB |
Output is correct |
7 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
267 ms |
20392 KB |
Output is correct |
2 |
Execution timed out |
1083 ms |
57712 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
623 ms |
36516 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
55488 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
55460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
75856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
76656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
77992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |