Problem:
 Score: 400 points    Problem Statement  Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.  Let the current time be time 0 . Kizahashi has N jobs numbered 1 to N .  It takes A_i units of time for Kizahashi to complete Job i . The deadline for Job i is time B_i , and he must complete the job before or at this time.  Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.  Can Kizahashi complete all the jobs in time? If he can, print Yes ; if he cannot, print No .      Constraints   All values in input are integers.  1 \leq N \leq 2 \times 10^5  1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)         Input  Input is given from Standard Input in the following format:  N  A_1  B_1  .  .  .  A_N  B_N       Output  If Kizahashi can complete all the jobs in time, print Yes ; if he cannot, print No .        Sample Input 1 5
2 4
1 9
1 8
4 9
3 12      Sample Output 1 Yes  He can complete all the jobs in time by, for example, doing them in the following order:   Do Job 2 from time 0 to 1 .  Do Job 1 from time 1 to 3 .  Do Job 4 from time 3 to 7 .  Do Job 3 from time 7 to 8 .  Do Job 5 from time 8 to 11 .   Note that it is fine to complete Job 3 exactly at the deadline, time 8 .       Sample Input 2 3
334 1000
334 1000
334 1000      Sample Output 2 No  He cannot complete all the jobs in time, no matter what order he does them in.       Sample Input 3 30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720      Sample Output 3 Yes

Solution (Python):
def main():
    n = int(input())
    abl = []
    for _ in range(n):
        a, b = map(int, input().split()) 
        abl.append([a,b])

    abl.sort(key=lambda x:x[1])
    curr_time = 0
    for curr_ab in abl:
        
        a,b = curr_ab
        curr_time += a
        if curr_time > b:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
ab = [0]*n
for i in range(n):
    ab[i] = list(map(int,input().split()))
ab.sort(key= lambda val : val[1])
ans = 1
t = 0
for i in range(n):
    t += ab[i][0]
    if ab[i][1] < t:
        ans = 0
if ans == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
n = int(input())
Jobs = []
for i in range(n):
    Jobs.append(list(map(int, input().split())))

Jobs.sort(key=lambda x: x[1], reverse=True)

now = Jobs[0][1]
for time, deadline in Jobs:
    if now < deadline:
        now -= time
    else:
        now = deadline
        now -= time
    
if now < 0:
    print("No")
else:
    print("Yes")

Solution (Python):
def cumsum(a):
    s = [0]
    for i in range(len(a)):
        s.append(s[i]+a[i][0])
    return s

n = int(input())
a_b = [list(map(int,input().split())) for _ in range(n)]
a_b = sorted(a_b,key=lambda x: x[1])

all = cumsum(a_b)

flag = 1
for i in range(n):
    if all[i+1] > a_b[i][1]:
        flag = 0
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

N = int(input())
tasks = sorted([list(map(int,input().split())) \
        for _ in range(N)],key = lambda x:(x[1]))
time = 0

for i in range(N) :
    time += tasks[i][0]
    if time > tasks[i][1] :
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
N = int(input())
AB = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x: x[1])
timesum = 0
for ab in AB:
    timesum += ab[0]
    if timesum > ab[1]:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
tasks = [list(map(int, input().split())) for i in range(N)]

tasks.sort(key=lambda x: x[1])
time = 0
for a, b in tasks:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n = int(input())
from collections import namedtuple
Task = namedtuple('Task',('time','limit'))
tasks=[]
import operator
for _ in range(n):
    tasks.append(Task(*map(int, input().split())))
tasks.sort(key=operator.attrgetter('limit'))

total=0
for task in tasks:
    total+=task.time
    if total > task.limit:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda ab: ab[1], reverse=True)
time = ab[0][1]
for [a, b] in ab:
    time = min(time, b)
    time -= a
    if time < 0:
        print("No")
        exit(0)

print("Yes")

Solution (Python):
n = int(input())
jobs = []

for i in range(n):
    ai, bi = map(int, input().split())
    jobs.append([ai, bi])

jobs = sorted(jobs, key=lambda x: x[1])

ans = "Yes"
limit = 0
time = 0
for job in jobs:
    time += job[0]
    limit = job[1]
    if limit < time:
        ans = "No"
        break

print(ans)

Solution (Python):
n = int(input())
ab = []
for _ in range(n):
    a,b = [int(x) for x in input().split()]
    ab.append([a,b])

ans = "Yes"
time = 0
AB = sorted(ab, key=lambda x: x[1])

for x in AB:
    time += x[0]
    if time > x[1]:
        ans = "No"
        break
print(ans)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








n=n0()
AB=n3(n)
AB.sort(key=lambda x:x[1])

time=0
f=True
for a,b in AB:
    time+=a
    if time<=b:
        pass
    else:
        f=False
        break
p0(f)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








n=n0()
AB=n3(n)
AB.sort(key=lambda x:x[1])

time=0
f=True
for a,b in AB:
    time+=a
    if time<=b:
        pass
    else:
        f=False
        break
p0(f)

Solution (Python):
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]

B=sorted(A,key=lambda x:x[1])
total=0
a=True
for i in range(N):
    total+=B[i][0]
    if total>B[i][1]:
        print("No")
        a=False
        break
if a==True:
    print("Yes")

Solution (Python):
N = int(input())
AB = [[int(i) for i in input().split()] for i in range(N)] 

AB.sort(key=lambda x:(x[1], x[0]))

hour = 0
for a, b in AB:
  hour += a
  if hour <= b:
    continue
  else:
    print('No')
    exit()

print('Yes')

Solution (Python):

import sys
try:
    from typing import List
except ImportError:
    pass

YES = "Yes"  
NO = "No"  


def solve(N: int, A: "List[int]", B: "List[int]"):
    tasks = sorted(zip(B, A))
    cum = 0
    for bi, ai in tasks:
        cum += ai
        if cum > bi:
            print(NO)
            return
    print(YES)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int()] * (N)  
    B = [int()] * (N)  
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    t = 0
    f = False
    for i, j in c:
        t += i
        f = f or t > j

    print('No' if f else 'Yes')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    t = 0
    for i, j in c:
        t += i
        if t > j:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    d, f = zip(*c)
    for i, j in zip(accumulate(d), f):
        if i > j:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())

    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    d, f = zip(*c)
    
    g = all(i <= j for i, j in zip(accumulate(d), f))
    print('Yes' if g else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    *d, = map(lambda x: x[0], c)
    *f, = map(lambda x: x[1], c)
    t = list(accumulate(d))
    g = all(i <= j for i, j in zip(t, f))
    print('Yes' if g else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from collections import deque
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))

    c = deque(c)
    t = 0
    while c:
        d, f = c.popleft()
        t += d
        if f < t:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
from heapq import heappush, heappop
n = int(input())
q = []
for _ in range(n):
    a, b = map(int, input().split())
    heappush(q, (b, a))

time = 0
while q:
    deadline, cost = heappop(q)
    time += cost
    if deadline < time:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import numpy as np
n = int(input())
ab = np.zeros((n, 2))
for i in range(n):
    l = list(map(int, input().split()))
    ab[i, :] = l
ab = ab[np.argsort(ab[:, 1])]
a_cum = np.cumsum(ab[:, 0])
for i in range(n):
    if a_cum[i] > ab[i, 1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
N = int(input())
BA = []
for i in range(N):
    A, B = map(int, input().split())
    BA.append([B, A])
BA = sorted(BA)
TIME = 0
for i in BA:
    TIME += i[1]
    if TIME > i[0]:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
A = sorted(A, key = lambda x: x[1])
t = 0
for a, b in A:
    t += a
    if t > b:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())

work = []
for _ in range(N):
    A, B = map(int, input().split())
    work.append([B, A])
    
work.sort()



sum = 0
for i in range(N):
    sum += work[i][1]
    
    if sum > work[i][0]:
        print("No")
        exit()
        
print("Yes")

Solution (Python):
def main():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    total_time = 0
    for time, deadline in sorted(AB, key=lambda x: x[1]):
        total_time += time
        if total_time > deadline:
            print('No')
            break
    else:
        print('Yes')
main()

Solution (Python):
n = int(input())
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append([a,b])
li = sorted(li,key = lambda x:x[1])
ok = True
sa = 0
for i in range(n):
    
    f,s = li[i]
    sa += f
    if sa > s:
        ok = False
print('Yes' if ok else 'No')

Solution (Python):
n= int(input())
task = [list(map(int,input().split()))for i in range(n)]

task.sort(key= lambda x: x[1])
time = 0
for i in range(n):
    time += task[i][0]
    if time > task[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
BA = []
for _ in range(N):
    a, b = map(int, input().split())
    BA.append([b, a])
BA.sort()

sum_time = 0
for i in range(N):
    sum_time += BA[i][1]
    if sum_time > BA[i][0]:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n = ii()
l = []
for _ in range(n):
    l.append(iil())

l.sort(key=lambda x:x[1])

time = 0

for item in l:
    time += item[0]
    if time <= item[1]:
        continue
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
import sys
import numpy as np

n = int(input())
tasks = np.fromstring(sys.stdin.read(), sep=' ').reshape((n, 2))
a = tasks[:, 0]
b = tasks[:, 1]
i = b.argsort()
print('Yes' if (np.add.accumulate(a[i]) <= b[i]).all() else 'No')

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
works = []
for i in range(N):
    a, b = getNM()
    works.append([a, b])
works.sort(key = lambda i: i[1])

done = 0
flag = True
for w in works:
    done += w[0]
    if done > w[1]:
        flag = False
print('Yes' if flag else 'No')

Solution (Python):
import sys
N = int(input())
task = list()
for _ in range(N):
  task.append(list(map(int,input().split())))
task.sort(key=lambda x:x[1])
time = 0
for i in range(N):
  time += task[i][0]
  if time > task[i][1]:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
N = int(input())
time = 0
A = []
for i in range(N):
    a,b = map(int, input().split())
    A.append([b,a])
A.sort()
for i in range(N):
    time += A[i][1]
    if time > A[i][0]:
        print("No")
        exit()
print("Yes")

Solution (Python):
n=int(input())
task=[list(map(int,input().split())) for _ in range(n)]
task.sort(key=lambda x: x[1])

deadline=0
now=0
for i in range(n):
    now += task[i][0]
    deadline = task[i][1]
    if now > deadline:
        print('No')
        exit()

print('Yes')

Solution (Python):
N = int(input())
A_B = [[0 for _ in range(2)] for _ in range(N)]
total = 0
res = 'Yes'
for i in range(N):
  A_B[i][0], A_B[i][1] = map(int, input().split(' '))
A_B.sort(key=lambda x: x[1])
for i in range(N):
  total += A_B[i][0]
  if total > A_B[i][1]:
    res = 'No'
    break
print(res)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N =  I()
L = ILL(N)

L = sorted(L, key=lambda x: x[1])

now = 0
for a,b in L:
  now += a
  if now>b:
    PE("No")
P("Yes")

Solution (Python):


n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]


ab = sorted(ab, key=lambda x: x[1])

weight = 0
for w, d in ab:
    
    weight += w
    if weight > d:
        print("No")
        exit()

print("Yes")

Solution (Python):
N=int(input())

task=[]
for _ in range(N):
    A,B=map(int,input().split())
    task.append([B,A])
task.sort()

S=0
ans="Yes"
for i in range(N):
    S+=task[i][1]
    if S>task[i][0]:
        ans="No"
        break
print(ans)

Solution (Python):
n = int(input())
L = [list(map(int, input().split())) for _ in range(n)]
L.sort(key=lambda x:x[1])
time = 0
for i in range(n):
    time += L[i][0]
    if time > L[i][1]:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])

time=0
for i in range(n):
  time+=ab[i][0]
  if time>ab[i][1]:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
import sys

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

now = 0

for a, b in ab:
    now += a
    if now > b:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
N = int(input())
L = []

for _ in range(N):
  A, B = map(int, input().split())
  L.append([A, B])

L.sort( key = lambda x: x[1])

T = 0

for AB in L:
  T += AB[0]
  if T > AB[1]:
    print("No")
    exit()

print("Yes")

Solution (Python):
n=int(input())

tmp=[]
for _ in range(n):
    tmp.append(list(map(int,input().split())))

tmp.sort(key=lambda x:x[1])

t = 0
for a,b in tmp:
    t+=a
    if b < t:
        print("No")
        exit()

print("Yes")

Solution (Python):
n = int(input())
job = [list(map(int, input().split())) for _ in range(n)]


job.sort(key=lambda x: x[1])


time = 0

for i in range(n):
  time += job[i][0]
  
  if time > job[i][1]:
    print("No")
    quit()
print("Yes")

Solution (Python):
def main():
    N = int(input())
    work = []
    for _ in range(N):
        A, B = map(int, input().split())
        work.append((B,A))

    work.sort()
    
    time = 0
    for b, a in work:
        if b < time + a:
            print('No')
            exit()
        time += a
    print('Yes')

    



if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
dct = {}
falseflag = 0
now = 0
for i in range(N):
  A,B = list(map(int, input().split()))
  if( B not in dct):
    dct[B] = [A]
  else:
    dct[B].append(A)
worklist = sorted(dct.items())
for i in range(len(worklist)):
  now += sum(worklist[i][1])
  if(now > worklist[i][0]):
    falseflag = 1
    break
if(falseflag==0):
  print("Yes")
else:
  print("No")

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div

N = ri()
d = [ri_() for i in range(N)]
d.sort(key=itemgetter(1))
sm = 0
for di in d:
    sm += di[0]
    if sm > di[1]:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    AB = []
    for _ in range(N):
        A, B = map(int, readline().split())
        AB.append((A,B))
    AB.sort(key=lambda x:x[1])
    time_count = 0
    for i in range(N):
        A = AB[i][0]
        B = AB[i][1]
        time_count += A
        if time_count>B:
            print('No')
            break
        else:
            continue
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
t,s=0,0
for a,b in ab:
  t=b
  s+=a
  if s<=t:
    pass
  else:
    print("No")
    exit(0)
print("Yes")

Solution (Python):
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[1])

cost = [0 for i in range(n+1)]
time = [0 for i in range(n+1)]
for i in range(1,n+1):
  cost[i] = cost[i-1] + a[i-1][0]
  time[i] = a[i-1][1]

flag = True
for c, t in zip(cost, time):
  if c > t:
    flag = False
    break
print("Yes" if flag else "No")

Solution (Python):
N = int(input())
w = [list(map(int, input().split())) for i in range(N)]
w.sort(key = lambda w : w[1])
t = 0
for i in range(N):
    t += w[i][0]
    if t > w[i][1]:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
from sys import exit

n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab, key = lambda x : x[1])

total = 0
for a,b in ab:
    total += a
    if total <= b:
        continue
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
N = int(input())

arr = []

for i in range(N):
  a,b = map(int,input().split())
  arr.append([b,a])
  
arr.sort()

t = 0
ck=0

for i in range(N):
  a = arr[i][0]
  b = arr[i][1]
  t += b  
  if t > a:
    ck = 1

print("Yes" if ck == 0 else "No")

Solution (Python):
def solve():
  n = int(input())
  works = [list(map(int, input().split())) for i in range(n)]
  works = sorted(works, key=lambda x:x[1])
  if works[0][0] > works[0][1]:
    print("No")
    exit()
  sum = 0
  for i in works:
    sum += i[0]
    if sum > i[1]:
      print("No")
      exit()
  print("Yes")
  return 0
 
if __name__ == "__main__":
  solve()

Solution (Python):
n = int(input())

a = []
b = []

for i in range(n):
    A, B = [int(i) for i in input().split()]
    a.append(A)
    b.append(B)

works = []

for i in range(n):
    works.append((b[i], a[i]))

works.sort()

t = 0
end = False

for b, a in works:
    t += a
    if t > b:
        print('No')
        end = True
        break

if not end:
    print("Yes")

Solution (Python):
n = int(input())
job = []
for i in range(n):
    a, b = map(int, input().split())
    job.append([b, a])
job.sort()
time = 0
for i in range(n):
    time += job[i][1]
    if time > job[i][0]:
        print('No')
        exit()
print('Yes')

Solution (Python):
import heapq 
n = int(input())
li = []
heapq.heapify(li)
for i in range(n):
    a,b = map(int,input().split())
    heapq.heappush(li,(b,a))
t = 0
while li:
    b,a = heapq.heappop(li)
    t+=a
    if t>b:
        print('No');exit()
print('Yes')

Solution (Python):
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort(key= lambda x:x[1])
time = 0
for i in range(n):
    if a[i][1] < time + a[i][0]:
        print("No")
        exit()
    else:
        time += a[i][0]
print("Yes")

Solution (Python):
def resolve():
    N = int(input())

    jobs = []
    for i in range(N):
        aa, bb = map(int, input().split())
        jobs.append([aa, bb])

    jobs.sort(key=lambda key: key[1])

    now = 0
    for job in jobs:
        now += job[0]
        limit = job[1]
        if now > limit:
            print('No')
            return

    print('Yes')


resolve()

Solution (Python):

import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A, B = [0]*N, [0]*N
time = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    A[i] = a
    B[i] = b

tmp = zip(B, A)
tmp = sorted(tmp)
for b, a in tmp:
    time += a
    if (time > b):
        print('No')
        exit()
print('Yes')

Solution (Python):
def check():
    N = int(input())
    X = [list(map(int, input().split())) for _ in range(N)]
    X.sort(key=lambda x:x[1])
    now = 0
    for a,b in X:
        now += a
        if now>b:
            return 'No'
    return 'Yes'
print(check())

Solution (Python):
n = int(input())
ab = [[int(i) for i in input().split()] for j in range(n)]
ab.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1])
now = 0
for i in range(n):
    a, b = ab[i]
    now += a
    if b < now:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
job_list = []
for i in range(n):
    a, b = map(int, input().split())
    job_list.append((a, b))
job_list.sort(key=lambda x: x[1])

time = 0
for a, b in job_list:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,=pin()
    AB=[tupin() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    
    time=0
    for i in range(N):
        time+=AB[i][0]
        if time>AB[i][1]:
            print("No")
            return
    print("Yes")
        

resolve()

Solution (Python):
from operator import itemgetter

n = int(input())
ab =  [list(map(int,input().split())) for i in range(n)]

ab = sorted(ab,key=itemgetter(1),reverse = False)

cnt = 0
flag = True
for i in range(n):
    cnt += ab[i][0]
    if cnt > ab[i][1]:
        flag = False
if flag :
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)




input_list = lambda : list(map(int,input().split()))
import fractions

n=int(input())
a=[input_list() for _ in range(n)]
a.sort(key=lambda x:x[1])
cal=0
for each in a:
    v=each[0]
    cal+=v
    if cal>each[1]:
        print("No")
        exit()


print("Yes")

Solution (Python):
n = int(input())
arr = []
for i in range(n):
    a = list(map(int,input().split()))
    a.reverse()
    arr.append(a)
arr.sort()
tot = 0
for ab in arr:
    tot += ab[1]
    if tot>ab[0]:
        print('No')
        exit()

print('Yes')

Solution (Python):
n = int(input())
tasks = [list(map(int, input().split())) for i in range(n)]

tasks.sort(key=lambda x: x[1])
time = 0

for a, b in tasks:
  time += a
  if time > b:
    print("No")
    exit()
print("Yes")

Solution (Python):
n = int(input())

jobs = [None]*n
for i in range(n):
  a, b = map(int, input().split())
  jobs[i] = (b, a)

jobs.sort()

ans = True
sub = 0
for i in range(n):
  b, a = jobs[i][0], jobs[i][1]
  sub += a
  if sub > b:
    ans = False
    break

print("Yes" if ans else "No")

Solution (Python):
n=int(input())
h=[]
for i in range(n):
    a,b=map(int,input().split())
    h.append((a,b))
h.sort(key=lambda x: x[1])
s=0
for i in range(n):
    s+=h[i][0]
    if h[i][1]<s:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
N = int(input())

BA_dict = dict()

for i in range(N):
    A,B = map(int, input().split())
    
    if B not in BA_dict:
        BA_dict[B] = list()
        
    BA_dict[B].append(A)
    

BA_sorted = sorted(BA_dict.items(), key=lambda x:x[0])

now_time = 0
for BA in BA_sorted:
    deadline = BA[0]
    now_time += sum(BA[1])
    
    if now_time > deadline:
        print("No")
        break
else:
    print("Yes")

Solution (Python):

import itertools

n = int(input())
ab_list = [[None] * 2 for i in range(n)]
for i in range(n):
    ab_list[i] = list(map(int, input().split()))

ab_list.sort(key=lambda x:(x[1]))
ab_list_T = [list(x) for x in zip(*ab_list)]

cum_iter = itertools.accumulate(ab_list_T[0])

flag = True
for i,_ in enumerate(cum_iter):
    if _ > ab_list_T[1][i]:
        flag = False
    
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
p = []
for i in range(n):
    a,b = map(int,input().split())
    p.append([b,a])
p.sort()
q = 1
s = 0
for i in range(n):
    s += p[i][1]
    if p[i][0] >= s:
        continue
    else:
        q = 0
        print('No')
        break
if q == 1:
    print('Yes')

Solution (Python):
from operator import itemgetter
n = int(input())
data = []
for i in range(n):
    data.append(tuple(map(int,input().split())))

data.sort(key = itemgetter(1))

m = 0

for i, j in data:
    if m+i <= j:
        m += i
    else:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
from operator import itemgetter
n = int(input())
data = []
for i in range(n):
    data.append(tuple(map(int,input().split())))

data.sort(key = itemgetter(1))

m = 0

for i, j in data:
    if m+i <= j:
        m += i
    else:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
N = int(input())

work = []
for i in range(N):
    a, b = map(int, input().split())
    work.append(tuple((a, b)))

ws = sorted(work, key=lambda x:x[1])

time = 0
flg = "Yes"
for i in range(len(ws)):
    time += ws[i][0]
    if(time > ws[i][1]):
        flg = "No"
        break
print(flg)