#include <bits/stdc++.h>
using namespace std;
const int N = 50;
#define ll long long
map <ll, ll> cate;
map <ll, ll> dp;
set <ll> s;
ll v[N];
int main()
{
ll n, m, nr, i;
cin >> n >> m;
for (i = 1; i <= n; i++)
{
cin >> nr;
if (nr > m)
continue;
if (s.empty())
{
cate[nr] = 1;
s.insert(nr);
continue;
}
auto it = s.end();
while(it != s.begin())
{
it--;
ll val = *it;
if (val + nr > m)
continue;
if (cate[val + nr] == 0)
s.insert(val + nr);
cate[val + nr] += cate[val];
}
if (cate[nr] == 0)
s.insert(nr);
cate[nr]++;
}
ll ans = 0;
for (auto it : cate)
ans += it.second;
cout << ans + 1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
8004 KB |
Output is correct |
2 |
Correct |
16 ms |
3556 KB |
Output is correct |
3 |
Correct |
35 ms |
7132 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
616 ms |
115272 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
459 ms |
84872 KB |
Output is correct |
2 |
Correct |
34 ms |
7236 KB |
Output is correct |
3 |
Correct |
30 ms |
5784 KB |
Output is correct |
4 |
Correct |
10 ms |
1988 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
75 ms |
14532 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
2288 KB |
Output is correct |
2 |
Execution timed out |
1079 ms |
55668 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
130 ms |
4000 KB |
Output is correct |
2 |
Correct |
791 ms |
24884 KB |
Output is correct |
3 |
Correct |
58 ms |
1604 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
259 ms |
10020 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
49148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
228124 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
225864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1096 ms |
227060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |