#P3821. Isaac's Unscathed Final Challenge
Isaac's Unscathed Final Challenge
Isaac's Unscathed Final Challenge
In this problem, you control Isaac and must help him pass the final level without taking any damage. There are several enemies he must face. To avoid injury, his current blood (health) B must be strictly greater than the attack power of every enemy he faces. Given the maximum allowable blood M (since blood cannot exceed a certain limit), determine if Isaac can clear the level unscathed. If it is possible, output the minimum blood B required; otherwise, output IMP0SSBLE!!
.
Formally, you are given an integer n and a limit M. You are also given n integers representing the attack power of each enemy. To pass an enemy safely, Isaac’s blood B must satisfy:
[ B > A_i \quad \text{for all } 1 \leq i \leq n, ]
The minimal blood required is therefore B = max(Ai) + 1
. However, if this minimal value exceeds M, then it is impossible for Isaac to be unscathed and you should output IMP0SSBLE!!
.
inputFormat
The first line contains two space-separated integers n and M (1 ≤ n ≤ 105, 1 ≤ M ≤ 109), where n is the number of enemies and M is the maximum allowable blood.
The second line contains n space-separated integers: A1, A2, ..., An (0 ≤ Ai < M), representing the attack power of each enemy.
outputFormat
If it is possible for Isaac to complete the level without injury, output the minimum required blood B (which equals max(Ai) + 1
). Otherwise, output IMP0SSBLE!!
(without quotes).
sample
3 100
5 10 3
11