#C3866. Knight vs. Dragons

    ID: 47340 Type: Default 1000ms 256MiB

Knight vs. Dragons

Knight vs. Dragons

A brave knight is about to face a series of fearsome dragons. Initially, the knight has a strength of s. There are n dragons, each with a strength given in an array. The knight will battle the dragons in a specific order that is determined by sorting the dragons in descending order of their strengths.

During each battle, the knight can defeat a dragon only if his current strength is strictly greater than the dragon’s strength. Once he defeats a dragon, his strength increases by the strength of that dragon. Your task is to determine whether the knight, following the descending order of battles, can defeat all the dragons without his strength ever being less than or equal to any dragon’s strength before the fight.

Note: The dragons must be fought in the descending order of their strengths.

inputFormat

The input is given via standard input and consists of two lines:

  • The first line contains two integers n and s separated by a space, where n is the number of dragons and s is the initial strength of the knight.
  • The second line contains n space‐separated integers, each representing the strength of a dragon.

outputFormat

Output a single line: YES if the knight can defeat all dragons in the given (descending) order, or NO if he cannot.

## sample
3 8
5 4 3
YES

</p>