#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
map<ll, ll> dp;
ll border = 1e5 + 10;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
for (int i = -border; i <= border; i++) dp[i] = -1e18 - 10;
dp[0] = 0;
ll M, L;
cin >> M >> L;
for (ll i = -M; i <= M; i++)
{
ll A;
cin >> A;
int c = 1;
if (i < 0) c = -1;
//cerr << c << '\n';
for (int t = c*border; abs(t) <= border; t -= c)
{
for (ll k = 1; k <= A; k++) dp[t] = max(dp[t], dp[t - (i * k)] + k);
}
}
//for (int i = -6; i <= 6; i++) cerr << dp[i] << " ";
if (dp[L] <= -1e15 - 10) cout << "impossible";
else cout << dp[L];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
554 ms |
12820 KB |
Output is correct |
2 |
Correct |
424 ms |
12820 KB |
Output is correct |
3 |
Correct |
317 ms |
12832 KB |
Output is correct |
4 |
Incorrect |
2631 ms |
12832 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
554 ms |
12820 KB |
Output is correct |
2 |
Correct |
424 ms |
12820 KB |
Output is correct |
3 |
Correct |
317 ms |
12832 KB |
Output is correct |
4 |
Incorrect |
2631 ms |
12832 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2638 ms |
12948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2638 ms |
12948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2638 ms |
12948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
554 ms |
12820 KB |
Output is correct |
2 |
Correct |
424 ms |
12820 KB |
Output is correct |
3 |
Correct |
317 ms |
12832 KB |
Output is correct |
4 |
Incorrect |
2631 ms |
12832 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2638 ms |
12948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
554 ms |
12820 KB |
Output is correct |
2 |
Correct |
424 ms |
12820 KB |
Output is correct |
3 |
Correct |
317 ms |
12832 KB |
Output is correct |
4 |
Incorrect |
2631 ms |
12832 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2638 ms |
12948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
554 ms |
12820 KB |
Output is correct |
2 |
Correct |
424 ms |
12820 KB |
Output is correct |
3 |
Correct |
317 ms |
12832 KB |
Output is correct |
4 |
Incorrect |
2631 ms |
12832 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |