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



Sample input:
5
2 4
1 9
1 8
4 9
3 12


Sample output:
Yes

Submission status: Accepted

Solution code:
n = int(input())

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

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

flag = True

now = 0


for job in ab:
  now += job[0]

  if now > job[1]:
    flag = False

if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
task = [0] * N
for i in range(N):
    task[i] = list(map(int, input().split()))

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

time = 0
prev_dd = 0
ans = 'Yes'
for t in task_sorted:
    time += t[1] - prev_dd
    prev_dd = t[1]
    time -= t[0]
    if time < 0:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

Solution code:
def doit(ab):
    ab = sorted(ab, key=lambda x: (x[1], x[0]))
    s = 0
    for a, b in ab:
        s += a
        if s > b:
            return "No"
    return "Yes"

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

Submission status: Accepted

Solution code:
N = int(input())

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

AB.sort()

Asum = 0
check = 0
for i in range(N):
    Asum += AB[i][1]
    if Asum > AB[i][0]:
        check = 1
        break

if check == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
AB=[]
for i in range(N):
    A,B,=map(int,input().split())
    AB.append([A,B])
AB.sort(key=lambda x:x[1])
t=0
for i in range(N):
    t+=AB[i][0]
    if t>AB[i][1]:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    work = {}
    for i in range(N):
        A, B = [int(n) for n in input().split()]
        if B not in work:
            work[B] = []
        work[B].append(A)
    times = list(work.keys())
    times.sort()
    cur = 0
    for t in times:
        for w in work[t]:
            cur += w
            if cur > t:
                print("No")
                return
    print("Yes")
main()

Submission status: Accepted

Solution code:
n = int(input())

dat = []

for i in range(n):
    a,b = map(int,input().split())
    dat.append((a,b))

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

now = 0
for l,t in dat:
    if now + l > t:
        print("No")
        exit(0)
    else:
        now += l
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

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

lst.sort()
t = 0
for i in range(N):
    t += lst[i][1] #仕事に使う時間をプラス
    if t > lst[i][0]: #制限時間と比較
        print ('No')
        exit()

print ('Yes')

Submission status: Accepted

Solution code:
from heapq import heappop, heappush

N = int(input())
h = []
res = 'Yes'

for i in range(N):
    A, B = map(int, input().split())
    heappush(h, (B, A))

t = 0
for i in range(N):
    B, A = heappop(h)
    t += A
    if t > B:
        res = 'No'

print(res)

Submission status: Accepted

Solution code:
N = int(input())
task = sorted([tuple(map(int, input().split())) for _ in  range(N)], key=lambda x:x[1])
t = 0
for a, b in task:
    t += a
    if t > b:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = onem()

s = []

for i in range(n):
    s.append(l())

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
INL = []
for i in range(N):
    a,b = LI()
    INL.append((b,a))
INL.sort()

cum = 0
for b, a in INL:
    cum += a
    if cum > b:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b = map(int, input().split())
# s = input()

N = int(input())
# A = [0]*(N)
# B = [0]*(N)
C = [0]*(N)

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

C.sort()
ans = "Yes"
cnt = 0
for (b, a) in C:
    cnt += a
    if cnt > b:
        ans = "No"
print(ans)

Submission status: Accepted

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

t = 0
ans = 'Yes'
for a_b in ab:
    t += a_b[0]
    if t > a_b[1]:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[1])
a = [0] * N
a[0] = X[0][0]
for i in range(1, N):
	a[i] = a[i - 1] + X[i][0]
for j in range(N):
	if a[j] > X[j][1]:
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)
mo=10**9+7

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

l.sort(key=lambda x: x[1])
t=0
k=0
for i in range(n):
    a,b=l[i]
    t+=a
    if t>b:
        k=1
        break
    
#a=[int(i) for i in input().split()]
#a=[l+i-1 for i in range(1,n+1)]


ans=['Yes','No']
print(ans[k])

Submission status: Accepted

Solution code:
import sys
N = int(input())
a = []
for i in range(N):
    A, B = map(int, input().split())
    a.append([A, B])
a = sorted(a, key=lambda x:x[1])
ans = 0
for x in a:
    ans += x[0]
    if ans > x[1]:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
works = [tuple(int(v) for v in input().split()) for _ in range(n)]

works = sorted(works, key=lambda w: w[1])

sum_a = 0
workable = True
for a, b in works:
    sum_a += a
    if sum_a > b:
        print('No')
        workable = False
        break

if workable:
    print('Yes')

Submission status: Accepted

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

A.sort(key=lambda x:x[1])
n = 0
ans = "Yes"

for a in A:
  n += a[0]
  if n > a[1]:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N = int(input())
AB = [ inpl() for i in range(N) ]
AB.sort(key=lambda x: x[1])
totaltime = 0
for time, deadline in AB:
    totaltime += time
    if totaltime > deadline:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
ab = []

for i in range(n):
    a, b = map(int, input().split())
    ab.append((b, a))

ba = list(sorted(ab))


now = 0
bad = False
for b, a in ba:
    now += a
    if now <= b:
        pass
    else:
        bad = True
        break

if bad:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
BA = [[0,0]for i in range(N)]
flag = True
for i in range(N):
    A,B = map(int,input().split())
    BA[i] = [B,A]
BA.sort()
time = 0
for b,a in BA:
    time += a
    if time > b:
        flag =False
print(["No","Yes"][flag])

Submission status: Accepted

Solution code:
n = int(input())
ab =[list(map(int,input().split())) for i 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')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
W = [list(map(int, input().split())) for n in range(N)]
W.sort(key=lambda l: l[1])

def f():
    now = 0
    for p, t in W:
        now += p
        if now > t:
            return False
    return True

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

Submission status: Accepted

Solution code:

N=input()

CC=[]
for _ in xrange(N):
    a,b=list(map(int,raw_input().strip().split(' ')))
    CC+=[(b,a)]

CC=sorted(CC)

pre_sum=0
bad=0
for i in xrange(len(CC)):
    b,a=CC[i]
    pre_sum+=a
    if pre_sum>b:
        bad=1

if bad==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

t = 0
for A, B in AB :
    t += A
    if t > B :
        print('No')
        break
else :
    print('Yes')

Submission status: Accepted

Solution code:
import sys


fin = sys.stdin.readline
N = int(fin())
work_list = [[int(elem) for elem in fin().split()] for _ in range(N)]
assert len(work_list[0]) == 2


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

for load, limit in work_list:
    if load + cur_past_time > limit:
        print("No")
        exit(0)
    cur_past_time += load
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
Tasks = [0]*N
for i in range(N):
    A,B = map(int,input().split())
    Tasks[i] = (B,A)

Tasks.sort()
s = 0
for B,A in Tasks:
    s += A
    if B < s:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
ab = [[int(x) for x in input().split()][::-1] for _ in range(int(input()))]
ab.sort()
ab.reverse()
d = 10000000000
for b,a in ab:
    b = min(b,d)
    d = b-a
if d < 0:
    print('No')    
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
a_b_list=[]
for i in range(n):
    c, d=map(int, input().split())
    a_b_list.append([c, d])
a_b_list.sort(key=lambda x:x[1])
time=0
flag=0
for i in range(len(a_b_list)):
    time=time+a_b_list[i][0]
    if not time<=a_b_list[i][1]:
        flag=1

if flag:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
v = list()
time = 0
for i in range(n):
    a, b = map(int, input().split())
    v.append([a, b])
v = sorted(v, key=lambda x: x[1])
for i in v:
    time += i[0]
    if time > i[1]:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
##!/usr/bin/env python3
import sys
# from operator import itemgetter
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

YES = "Yes"  # type: str
NO = "No"  # type: str

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))

    # write code
    Work = [[A[i], B[i]] for i in range(N)]
    Work.sort(key=lambda x: x[1])
    # print(Work)
    last = 0
    for i in range(N):
        last += Work[i][0]
        if last > Work[i][1]:
            print('No')
            break
        else:
            continue
    else:
        print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
tasks = []
for i in range(n):
    a,b = map(int, input().split())
    tasks.append((b,a))
tasks.sort()

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

Submission status: Accepted

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

D = sorted(D, key=lambda x: x[1])
pre = 0
for i in range(N):
    a, b = D[i]
    if pre + a > b:
        print('No')
        exit()
    else:
        pre += a

print('Yes')

Submission status: Accepted

Solution code:
# coding=utf-8


get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


N = get()
A = getss(N)


A.sort(key=lambda a: a[1])
cur = 0
for i, j in A:
    cur += i
    if cur > j:
        print "No"
        exit()

print "Yes"

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())

shigoto = np.zeros((n, 2), dtype=int)

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

sorted_shigoto = shigoto[np.argsort(shigoto[:, 1])]

mount = 0
ans = True
for now_shigoto in sorted_shigoto:
    mount += now_shigoto[0]
    if mount > now_shigoto[1]:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from heapq import *

def main():
  n = int(input())
  ab = []
  for _ in range(n):
    a, b = map(int, input().split())
    ab.append((b, a))
  heapify(ab)
  total = 0
  is_done = True
  while ab:
    _ab = heappop(ab)
    if total + _ab[1] <= _ab[0]:
      total += _ab[1]
    else:
      is_done = False
  if is_done:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

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

now = 0
flag = 1
for i in range(N):
    now += a[i][0]
    if now > a[i][1]:
        flag = 0
        break

if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def main():
  values = [list(map(int, input().split())) for _ in range(int(input()))]
  values.sort(key=lambda x: x[1])
  cost = 0

  for c, d in values:
    cost += c

    if d < cost:
      print('No')
      return

  print('Yes')


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()

tasks = []
for i in range(N):
    A, B = nl()
    tasks.append([A, B])

tasks = sorted(tasks, reverse=True, key=lambda x: x[1])
t = tasks[0][1] - tasks[0][0]
for task in tasks[1:]:
    t = min(task[1], t) - task[0]

if t < 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for i in range(n):
    a,b=map(int,input().split())
    s.append([b,a])
s.sort()
count=0
flag=0
for i in range(n):
    count+=s[i][1]
    if count>s[i][0]:
        flag=1
print("Yes" if flag==0 else "No")

Submission status: Accepted

Solution code:
N = int(input())

jobs = list(tuple(map(int,input().split())) for _ in range(N))

# starts = sorted((b-a,a) for a,b in jobs)

t = 0
for dt, due in sorted(jobs, key= lambda x: x[1]):
    if t + dt > due:
        print('No')
        break
    else:
        t += dt
else:
    print('Yes')

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    arr = [[]] * n
    for i in range(n):
        a, b = map(int, input().split())
        arr[i] = [a, b]
    arr.sort(key = lambda x: x[1])
    ok = 1
    s = 0
    for i in range(n):
        s += arr[i][0]
        if s > arr[i][1]:
            ok = 0
            break
    if ok:
        print("Yes")
    else:
        print("No")
    return 0

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key = lambda x: x[1])
ans = "Yes"

n = 0
for a, b in AB:
  n += a
  if n > b:
    ans = "No"
    break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A, B = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

a, b = zip(*sorted(zip(A, B), key=lambda t: t[1]))

t = 0
ans = 'Yes'
for x, y in zip(a, b):
    t += x
    if t > y:
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ab_arr = []
for _ in range(N):
    ab_arr.append(tuple([int(x) for x in input().split()]))

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

finish = True
time = 0
for a,b in ab_arr:
    time += a
    if time > b:
        finish = False

if finish:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N = ri()
AB = []
for i in range(N):
    a,b = rl()
    AB.append((a,b))

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

time = 0
res = 0
ans = 1
for a,b in AB:
    if time < b:
        res += (b-time)
        time = b
    if res >= a:
        res -= a
    else:
        ans = 0
        break

yn(ans)

Submission status: Accepted

Solution code:

N =int(input())
ab =[[int(i)for i in input().split()]for _ in range(N)]
ab.sort(key=lambda x:x[1])
t=0
sta = True
for a,b in ab:
    t += a
    if t > b:
        sta =False
        break
if sta:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
BA = []
for _ in range(N):
    a, b = map(int, input().split())
    BA.append((b, a))
BA.sort()
t = 0
for b, a in BA:
    t += a
    if t > b:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = "Yes"
time = 0
for a, b in works:
    time += a
    if time > b:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
n=int(input())
task=[list(map(int,input().split())) for _ in range(n)]
task.sort(key=lambda x:x[1])
time=0
for i in range(n):
    time+=task[i][0]
    if task[i][1]<time:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A, B = get_data(n, [int, int])
    sum = 0
    for a, b in sorted(zip(A, B), key=op.itemgetter(1)):
        sum += a
        if sum > b:
            print("No")
            return
    print("Yes")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = [list(li()) for _ in range(n)]

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

cur = 0

ans = True

for ai, bi in ab:
    cur += ai
    if cur > bi:
        ans = False

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

Submission status: Accepted

Solution code:
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
AB=sorted(AB,key=lambda x:x[1])
cnt=0
for i in range(N):
    cnt+=AB[i][0]
    if cnt>AB[i][1]:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
d=[]
for i in range(n):
    a,b=map(int,input().split())
    d.append((b,a))
d.sort()
chk=0
for i in d:
    chk+=i[1]
    if chk>i[0]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x:x[1])

temp_total = 0
for a,b in AB:
  temp_total += a
  if temp_total<=b:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int,input().split(' '))) for i in [0]*N]

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

t = 0
for a,b in AB:
	t += a
	if t > b:
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
        a,b=map(int,input().split())
        l.append([a,b])
l.sort(key=lambda x:x[1])
f=True
t=0
for i in range(n):
        t+=l[i][0]
        if t>l[i][1]:
                f=False
                break
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
  a,b = map(int,input().split())
  S.append([a,b])
ans = "Yes"
S.sort(key=lambda x:x[1])
a = 0
for i in range(N):
  a += S[i][0]
  if a>S[i][1]:
    ans = "No"
    break
print(ans)

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
tasks = [list(map(int, input().split() )) for _ in range(n)]
tasks.sort(key = itemgetter(1))
# 締切時刻をkeyとしてソート

t = 0
for i in range(n):
	t += tasks[i][0]
	if t > tasks[i][1]:
		print("No")
		exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
ba = []
for i in range(n):
    a, b = map(int, input().split())
    ba.append([b, a])
ba.sort()
now = 0
out = 0
for i, j in ba:
    now += j
    if now > i:
        out = 1
        break
if out:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc131/tasks/abc131_d

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

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

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

    possible = True
    current = 0
    for a, b in AB:
        current += a
        if current <= b:
            pass
        else:
            possible = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from operator import itemgetter
from itertools import accumulate
import sys
N = int(input())
AB = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)]
AB.sort(key = itemgetter(1))
A1, B1 = list(map(list, zip(*AB)))
SA = list(accumulate(A1))
if all(a <= b for a, b in zip(SA, B1)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

def debug(*args):
    import sys
    print(*args, file=sys.stderr)

def solve(N, BA):
    BA = sorted(BA)

    t = 0
    for b, a in BA:
        t += a
        if t > b:
            return "No"
    return "Yes"



def main():
    N = int(input())
    BA = []
    for _ in range(N):
        A, B = [int(x) for x in input().split()]
        BA.append(tuple([B, A]))

    print(solve(N, BA))

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    jobs = [tuple(map(int, input().split())) for _ in range(n)]
    jobs.sort(key=lambda x: (x[1], x[0]))

    t = 0
    for cost, deadline in jobs:
        t += cost
        if t > deadline:
            print('No')
            return
    print('Yes')


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: "List[int]"):
    A.sort(key=lambda x: x[1])
    current = 0
    for volume, deadend in A:
        current += volume
        if current > deadend:
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [tuple()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = (int(next(tokens)), int(next(tokens)))
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

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

now = 0
for a, b in ab:
	if b < now + a:
		print("No")
		break
	else:
		now += a
else:
	print("Yes")

Submission status: Accepted

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