C++20 sections · 1024 units
Open in Course

Problem - Dragons

Choosing opponents

You're a warrior with initial strength ss facing nn dragons. Each dragon has a strength level and a bonus you gain after defeating it. You can only defeat a dragon if your current strength is strictly greater than the dragon's strength.

Your task: determine if you can defeat all dragons by choosing them in the right order. If yes, output that order. This tests your understanding of sorting and how order affects outcomes.

Before reading on, think: if you have strength 1010 and face dragons with strengths 55 and 1515, which should you fight first? Why does order matter here?