#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, target; cin >> n >> target;
vector<int> coins(2*n+1);
for (int i = 0; i<2*n+1; i++) cin >> coins[i];
vector<int> coinsEXPL;
for (int i = 0; i<2*n+1; i++) {
for (int j = 0; j<coins[i]; j++) coinsEXPL.push_back(i-n);
}
unordered_map<int, int> dp;
dp[0] = 0;
for (int i: coinsEXPL) {
unordered_map<int, int> newDP = dp;
for (auto j: dp) {
cerr << j.first << " " << j.second << "\n";
newDP[j.first+i] = max(j.second+1, newDP[j.first+i]);
}
dp = newDP;
}
if (dp.count(target)) cout << dp[target] << "\n";
else cout << "impossible\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
28 ms |
356 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
10408 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
28 ms |
356 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
10408 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Runtime error |
425 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Runtime error |
425 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Runtime error |
425 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
28 ms |
356 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
10408 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Runtime error |
425 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
28 ms |
356 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
10408 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Runtime error |
425 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
28 ms |
356 KB |
Output is correct |
5 |
Execution timed out |
5063 ms |
10408 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |