2729 - SAO

From Bitnami MediaWiki
Revision as of 18:24, 29 March 2023 by Andor Giulia (talk | contribs) (Pagină nouă: == 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((re...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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>