#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 41;
unordered_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()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> mm;
for(int i = 0 ; i < n ; i++)
cin >> a[i];
cout << solve(0,0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
4008 KB |
Output is correct |
2 |
Correct |
14 ms |
2168 KB |
Output is correct |
3 |
Correct |
22 ms |
3496 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
706 ms |
47220 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
561 ms |
36064 KB |
Output is correct |
2 |
Correct |
41 ms |
5160 KB |
Output is correct |
3 |
Correct |
16 ms |
2680 KB |
Output is correct |
4 |
Correct |
9 ms |
1528 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
41 ms |
6072 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
105 ms |
14224 KB |
Output is correct |
2 |
Execution timed out |
1079 ms |
88828 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
219 ms |
25640 KB |
Output is correct |
2 |
Execution timed out |
1087 ms |
94808 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1061 ms |
56444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
86680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
86048 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1067 ms |
95988 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |