C++20 sections · 1024 units
Open in Course

Dragons - The Pattern

Weakest first

Here's what matters: always fight the weakest dragon you can defeat. If you skip a weak dragon to fight a strong one, you might not have enough strength to go back and defeat the weak one later.

If you fight the 88-strength dragon first and gain 33 bonus, you'll have 1313 strength.

The solution: sort dragons by strength and fight them in ascending order.