fork download
  1. a,b = map(int,input().split())
  2. c = {}
  3. for i in range(b):
  4. p,q = map(int,input().split())
  5. if p not in c:
  6. c[p] = list()
  7. c[p].append(q)
  8. r = sorted(c)
  9. for i in r:
  10. if i >= a:
  11. print("NO")
  12. break
  13. else:
  14. a += sum(c[i])
  15. print("YES")
Success #stdin #stdout 0.03s 9696KB
stdin
2 2
1 99
100 0
stdout
YES
YES
YES