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;
set<pair<long long int, long long int> > Valores;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int M, L;
cin >> M >> L; Valores.insert(make_pair(0LL, 0LL));
for (long long int i = -M; i <= M; i++)
{
long long int A;
cin >> A;
set<pair<long long int, long long int> > Novo;
for (auto val : Valores)
{
for (long long int k = 1; k <= A; k++) Novo.insert(make_pair(val.first + k*i, val.second + k));
}
for (auto newVal : Novo) Valores.insert(newVal);
}
long long int resp = -1;
for (auto val : Valores)
{
if (val.first == L) resp = max(resp, val.second);
}
if (resp == -1) cout << "impossible";
else cout << resp;
}
# | 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... |