This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |