#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
1108 KB |
Output is correct |
5 |
Execution timed out |
5040 ms |
39128 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
1108 KB |
Output is correct |
5 |
Execution timed out |
5040 ms |
39128 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
980 KB |
Output is correct |
2 |
Runtime error |
2525 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
980 KB |
Output is correct |
2 |
Runtime error |
2525 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
980 KB |
Output is correct |
2 |
Runtime error |
2525 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
1108 KB |
Output is correct |
5 |
Execution timed out |
5040 ms |
39128 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
980 KB |
Output is correct |
2 |
Runtime error |
2525 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
1108 KB |
Output is correct |
5 |
Execution timed out |
5040 ms |
39128 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
980 KB |
Output is correct |
2 |
Runtime error |
2525 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
1108 KB |
Output is correct |
5 |
Execution timed out |
5040 ms |
39128 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |