Defeat a sequence of dragons by training enough strength and then gaining their power.
You start with an initial strength . There are dragons, each described by a strength requirement and a bonus power .
You may defeat dragons in any order. To defeat a dragon, your current strength must be strictly greater than its requirement. After defeating it, your strength increases by its bonus power.
Determine whether you can defeat all dragons.
Choose an order of fighting so that every dragon can be defeated, or report that it is impossible.
YES if you can defeat all dragons.NO.Example 1
Input
2 2 1 99 100 1
Output
YES
Explanation
Fight the dragon requiring 1 first: strength becomes 101, so the second dragon is also beatable.
Example 2
Input
10 1 100 1
Output
NO
Explanation
Your strength never exceeds 100, so the only dragon cannot be defeated.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.