Dragons

题意翻译

小方在跟龙进行比赛,他要是想进入下一层级,就必须要击败在这一层级上的所有的n条龙。 小方和每一条龙都有一个可以用整数表示的力量值,在每一次战斗中,该次战斗的结果由战斗的双方的力量值所决定。在一开始,小方的力量值是s。 在任意一次战斗中,如果小方的力量值比第i条龙(1<=i<=n)的力量值大,那么小方可以击败这头龙并且获得额外的力量值y(i),如果小方的力量值不大于这头龙的力量值,那么小方将在这场战斗中死亡。 小方可以以任意的一个顺序和龙进行战斗。请编写程序确定小方是否可以继续进入下一层级的比赛,即击败所有的龙族并且自己没有任何损失。 输入格式 第一行包括2个用空格分隔的整数s,n,(1<=s<=10000,1<=n<=1000)表示小方初始的力量值和龙的总个数 接下来n行包含2个用空格分开的整数x(i),y(i) 表示第i头龙的力量值以及击败第i头龙可以获得的额外力量值 输出格式 一行,如果小方可以进入下一层级,则输出“YES”(不包含引号),否则输出“NO”(不包含引号)。 输入输出样例说明 在第一个样例中,小方力量初始值为2,第一条龙的力量值小于2,那么小方将击败他并获得额外的力量值99,此时小方的力量值为2+99=101,大于第二条龙的力量值,小方将击败他,因此小方可以进入下个层级。 在第二个样例中,小方力量初始值为10,小于唯一的一条龙的力量值100,那么小方将无法击败这条龙,因此无法进入下一层级。 感谢@wcy1056935201 提供翻译

题目描述

Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all $ n $ dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel's outcome is determined by their strength. Initially, Kirito's strength equals $ s $ . If Kirito starts duelling with the $ i $ -th ( $ 1<=i<=n $ ) dragon and Kirito's strength is not greater than the dragon's strength $ x_{i} $ , then Kirito loses the duel and dies. But if Kirito's strength is greater than the dragon's strength, then he defeats the dragon and gets a bonus strength increase by $ y_{i} $ . Kirito can fight the dragons in any order. Determine whether he can move on to the next level of the game, that is, defeat all dragons without a single loss.

输入输出格式

输入格式


The first line contains two space-separated integers $ s $ and $ n $ ( $ 1<=s<=10^{4} $ , $ 1<=n<=10^{3} $ ). Then $ n $ lines follow: the $ i $ -th line contains space-separated integers $ x_{i} $ and $ y_{i} $ ( $ 1<=x_{i}<=10^{4} $ , $ 0<=y_{i}<=10^{4} $ ) — the $ i $ -th dragon's strength and the bonus for defeating it.

输出格式


On a single line print "YES" (without the quotes), if Kirito can move on to the next level and print "NO" (without the quotes), if he can't.

输入输出样例

输入样例 #1

2 2
1 99
100 0

输出样例 #1

YES

输入样例 #2

10 1
100 100

输出样例 #2

NO

说明

In the first sample Kirito's strength initially equals 2. As the first dragon's strength is less than 2, Kirito can fight it and defeat it. After that he gets the bonus and his strength increases to $ 2+99=101 $ . Now he can defeat the second dragon and move on to the next level. In the second sample Kirito's strength is too small to defeat the only dragon and win.