2729 - SAO
Rezolvare
<syntaxhighlight lang="python" line="1"> n = int(input("Introduceti numarul de monstri: ")) monsters = [] for i in range(n):
res, pow = map(int, input(f"Introduceti rezistenta si puterea monstrului {i+1}: ").split()) monsters.append((res, pow))
m = int(input("Introduceti numarul de oferte: ")) offers = [] for i in range(m):
res, pow, price = map(int, input(f"Introduceti rezistenta, puterea si pretul ofertei {i+1}: ").split()) offers.append((res, pow, price))
min_cost = float('inf') for offer in offers:
armor_res, sword_pow, price = offer if all(armor_res > monster[1] and sword_pow > monster[0] for monster in monsters): min_cost = min(min_cost, price)
if min_cost == float('inf'):
print(-1)
else:
print(min_cost)
</syntaxhighlight>