Codeforces Round 142 (Div. 2)
A
Dragons
Codeforces
1000
原题
←B →
翻译中…

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.

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

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.

翻译中…

Note

翻译中…

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.

翻译中…

样例

Input #1
2 2
1 99
100 0
Output #1
YES
InputCopy OutputCopy
Input #2
10 1
100 100
Output #2
NO
InputCopy OutputCopy
题目信息
题号
230A
时间限制
2 s
内存限制
256 MB
标签
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。