newton/solutions/230A.py

19 lines
310 B
Python
Raw Normal View History

2025-01-14 22:52:41 +00:00
import sys
s, n = [int(d) for d in input().split(' ')]
dragons = []
for _ in range(n):
dragons.append([int(d) for d in input().split(' ')])
dragons = sorted(dragons, key=lambda x: x[0])
for i in dragons:
if s > i[0]:
s += i[1]
else:
print("NO")
sys.exit()
print("YES")