#P4025. Defeat the Monsters

    ID: 17273 Type: Default 1000ms 256MiB

Defeat the Monsters

Defeat the Monsters

In a computer game, you are required to defeat \(n\) monsters numbered from \(1\) to \(n\). To defeat the \(i\)-th monster, you must spend \(d_i\) units of life, but after defeating it, the monster drops a health potion that restores \(a_i\) units of life.

The battles occur sequentially. Before attacking a monster, your current life must be strictly greater than \(d_i\); that is, it is required that your life never falls to \(0\) or below at any point. Initially, you start with \(H\) units of life. The order in which you fight the monsters can be rearranged arbitrarily.

Determine whether there exists an order in which you can defeat all \(n\) monsters without your life ever falling to \(0\) or below.

inputFormat

The first line contains two integers \(n\) and \(H\) where \(n\) is the number of monsters and \(H\) is your initial life.

The second line contains \(n\) integers: \(d_1, d_2, \ldots, d_n\) representing the life cost to defeat each monster.

The third line contains \(n\) integers: \(a_1, a_2, \ldots, a_n\) representing the life you regain after defeating each monster.

outputFormat

Output a single line containing YES if there exists an order to defeat all the monsters without your life ever falling to \(0\) or below. Otherwise, output NO.

sample

3 10
3 5 7
4 1 5
YES