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: Wrong Answer

Solution code:
n = int(input())

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

aa = [a[0] for a in ab]
bb = [a[1] for a in ab]
sa = sum(aa)
mb = max(bb)

if sa <= mb:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
arr = []
for _ in range(int(input())):
    ab = list(map(int, input().split()))
    ab.sort(reverse=True)
    arr.append(ab)
arr.sort()
time = 0
for k in range(len(arr)):
    time += arr[k][1]
    if time > arr[k][0]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
a, b = zip(*ab)
a = list(a)
b = list(b)
a.sort()
b.sort()
a = list(accumulate(a))
for i, j in zip(a, b):
    if i > j:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

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

import sys
# sys.setrecursionlimit(100000)
import heapq


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


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


def main():
    """
    締切がはやい順に仕事を行う。
        全て完了できれば: Yes
        できなければ: No
    """
    n = input_int()
    hq = []
    for _ in range(n):
        a, b = input_int_list()
    heapq.heappush(hq, (b, a))
    t = 0
    while hq:
        b, a = heapq.heappop(hq)
        t += a
        if t > b:
            print("No")
            return
    print("Yes")
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

time=0

for i in lst:
  time+=i[0]
  if time>i[1]:
    print('NO')
    exit()
    
    
print('YES')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
C = list(zip(B, A))
C.sort()
B, A = zip(*C)
t = 0
for c in C:
    t += c[1]
    if t <= c[0]:
        continue
    else:
        print('no')
        exit()
print('yes')

Submission status: Wrong Answer

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

ab.sort(key = lambda x: x[1])
ok = True
last = 0
for a,b in ab:
    if b-a>last:
        last += a
    else:
        ok = not ok
print('Yes' if ok else 'No')

Submission status: Wrong Answer

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

ab.sort(key = lambda x: x[1])
ok = True
last = 0
for a,b in ab:
    if b-a>=last:
        last += a
    else:
        ok = not ok
print('Yes' if ok else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
c = b.copy()
c.sort()
wa = 0
for i in c:
    wa += a[b.index(i)]
    if wa > i:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
c = b.copy()
c.sort()
wa = 0
for i in c:
    wa += a[b.index(i)]
    if wa > b[b.index(i)]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
sa = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
c = b.copy()
c.sort()
wa = 0
for i in c:
    wa += a[b.index(i)]
    if wa > b[b.index(i)]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
sa = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
c = b.copy()
c.sort()
wa = 0
for i in c:
    wa += a[b.index(i)]
    print(wa, b[c.index(i)])
    if wa > b[b.index(i)]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
sa = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    sa[i] = b[i] - a[i]
# so = sa.copy()
# sa.sort()
c = b.copy()
c.sort()
# print(sa)
# print(so)
# print(su)
wa = 0
for i in c:
    wa += a[b.index(i)]
    # print(wa, b[c.index(i)])
    if wa > b[b.index(i)]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
sa = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    sa[i] = b[i] - a[i]
so = sa
sa.sort()
wa = 0
for i in sa:
    wa += a[so.index(i)]
    if wa > b[so.index(i)]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import math


N = int(input())

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

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

sum_time = 0
for i in timelis:
    need = i[0]
    deadline = i[1]

    sum_time = sum_time + need

    if sum_time > deadline:
        print(sum_time,need,deadline)
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import math


N = int(input())

timelis = []
for _ in range(N):
    A,B = map(int, input().split())
    if A >= B:
        print("No")
        sys.exit()
    timelis.append([A,B])

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

sum_time = 0
for i in timelis:
    need = i[0]
    deadline = i[1]

    sum_time = sum_time + need

    if sum_time > deadline:
        print(sum_time,need,deadline)
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
time=0
alist=[]
ans='Yes'
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b<a:
    ans='No'
alist.sort(key=lambda x: x[1])
time=0
for i in range(n):
  if time>alist[i][1]:
    ans='No'
  time+=alist[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
time=0
alist=[]
ans='Yes'
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b<a:
    ans='No'
alist.sort(key=lambda x: x[1])
time=0
for i in range(n):
  print(time)
  if time>alist[i][1]:
    ans='No'
  time+=alist[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
time=0
alist=[]
ans='Yes'
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b>time:
    time=b
  if b>a:
    ans='No'
alist.sort(key=lambda x: x[1])
for i in range(n-1,-1,-1):
  if time<alist[i][1]:
    ans='No'
  time=time-alist[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
time=0
alist=[]
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b>time:
    time=b
alist.sort(key=lambda x: x[1])
ans='Yes'
for i in range(n-1,-1,-1):
  if time<alist[i][1]:
    ans='No'
  time=time-alist[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ab = [[] for _ in range(n)]
az = [None] * n
bz = [None] * n
task = set()
flag = True
for i in range(n):
    ab[i] = list(map(int, input().split()))
    az[i], bz[i] = ab[i]


for a, b in ab:
    if (a, b) in task:
        flag = False
    else:
        task.add((a, b))
    if a > b:
        flag = False

if sum(az) > max(bz):
    flag = False
else:
    flag = True

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

Submission status: Wrong Answer

Solution code:
import sys
input =sys.stdin.readline
from collections import OrderedDict

N=int(input().rstrip('\n'))
s = OrderedDict()
for _ in range(N):
  A,B = (int(x) for x in input().rstrip('\n').split())
  s[A] = B
s2 = OrderedDict(sorted(s.items(),key = lambda x : x[1]))
used = 0
now = 0
check = 0
for a,b in s2.items():
  used += a
  if used > b:
    check += 1
    print('No')
    break
if check == 0:
  print('Yes')

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    task = [[int(item) for item in input().split()] for _ in range(N)]

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

    res = task[0][1]
    for time, lim in task:
        res -= time
        if res > lim:
            res = lim

    print('Yes') if res >= 0 else print('No')
    
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
a=defaultdict(list)
n = int(input())
for i in range(n):
    h,m=list(map(int,input().split()))
    a[m].append(h)
t=0
r=0

for i in a:
    for j in a[i]:
        t+=j
    if t>i:
        r=1
        break
if r==1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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])
tmp=0
for i in range(n):
    tmp+=l[i][0]
    if tmp>l[i][1]:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

Solution code:
N = int(input())

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

A, B = sorted(A), sorted(B)

max_B = max(B)
sum_A = sum(A)

if (sum_A > max_B):
    print('No')
    exit()
else:
    count = 0
    for i in range(N):
        count += A[i]

        if (count > B[i]):
            print('No')
            exit()
        else:
            continue

    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
for i in range(N):
    A,B = map(int,input().split())
    lst.append([B,A])
    
lst.sort()  
left = lst[0][0] - lst[0][1]

for i in range(1,N):
    left = left + (lst[i][0] - lst[i-1][0])
    left -= lst[i][1]
    if left < 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
nb = int(input())
somme = 0
mmax = 0
for loop in range(nb):
  n,m = map(int,input().split())
  if n<=m:
    somme+=n
  if m>mmax:
    mmax = m
if somme<=mmax:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
nb = int(input())
somme = 0
mmax = 0
for loop in range(nb):
  n,m = map(int,input().split())
  somme+=n
  if m>mmax:
    mmax = m
if somme<=mmax:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
nb = int(input())
somme = 0
mmax = 0
for loop in range(nb):
  n,m = map(int,input().split())
  somme+=n
  if m>mmax:
    mmax = m
if somme<=mmax:
  print("yes")
else:
  print("no")

Submission status: Wrong Answer

Solution code:
N = int(input())
C = {}

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

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

Submission status: Wrong Answer

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], x[0]))

gokei = 0
for i in A:
    gokei += i[0]
    if gokei > i[1]:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

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

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if t<=l[1]:
		ans = 'No'
		break
print(ans)

Submission status: Wrong Answer

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

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

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if l[1]<=t:
		ans = 'No'
		break
print(ans)

Submission status: Wrong Answer

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

tsk.sort(key = lambda x:x[2])

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if l[1]<=t:
		ans = 'No'
		break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

n = int(input())
task_dict = {}
a_l = []
b_l = []

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

deque = deque()
dl_set = set(task_dict.keys())
t = max(dl_set)

for i in range(t+1)[::-1]:
	if i in dl_set:
		deque.extend(task_dict[i])
	if i <= t:
		if deque:
			nes_time = deque.pop()
			t -= nes_time

if t >= 0 and len(deque) == 0:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

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

tsk.sort(key = lambda x:x[2])

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if l[1]<t:
		ans = 'No'
		break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import copy
li1=list()
li2=list()
N=int(input())
for i in range(N):
  A,B=map(int,input().split())
  li1.append(B)
  li2.append(A)
L=copy.copy(li1)
L=sorted(set(L))
li2 = [[li2[i1] for i1 in range(len(li1)) if li1[i1] == idx] for idx in sorted(set(li1))]
for i in range(len(L)):
  if L[i]<sum(li2[i]):
    print("No")
    sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)], key=itemgetter(1))

count = 0
Work = True
for i in range(n):
    if count > l[i][1]:
        Work = False
        break
    else:
        count += l[i][0]

if count > l[n-1][1]:
    Work = False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [None for _ in range(N)]
for i in range(N):
  X[i] = list(map(int,input().split()))
A = [None for _ in range(N)]
B = [None for _ in range(N)]
for i in range(N):
  A[i] = X[i][0]
  B[i] = X[i][1]
  
S = sum(A)
MAX = max(B)

if S > MAX:
  print('No')
  exit()

for i in range(N):
  if X[i][0] > X[i][1]:
    print('No')
    exit()
    
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [None for _ in range(N)]
for i in range(N):
  X[i] = list(map(int,input().split()))
A = [None for _ in range(N)]
B = [None for _ in range(N)]
for i in range(N):
  A[i] = X[i][0]
  B[i] = X[i][1]
  
S = sum(A)
MAX = max(B)

if S > MAX:
  print('No')
  exit()
else:
  print('Yes')
  exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N = NI()
    A = []
    for i in range(N):
        a, b = NMI()
        A.append([a, b])
    A.sort(key=lambda x: x[1])
    t = 0
    for a in A:
        if t > a[1]:
            print("No")
            exit()
        t += a[0]
    if t > A[-1][1]:
        print("No")
        exit()
    print("Yes")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
f = []
for _ in range(n):
    a, b = map(int, input().split())
    f.append((a, b, b - a))
f.sort(key=lambda x: x[2], reverse=True)
t = f[0][1]
stock = []
delta = 0
for a, b, c in f:
    if t < c:
        print('No')
        sys.exit()
    elif t == c:
        t -= a
    elif not stock:
        stock.append((a, b, c))
        delta = t - c
    else:
        if a <= delta:
            t -= a
            delta -= a
        else:
            a0, b0, c0 = stock.pop()
            t -= a0
            delta = t - c
            stock.append((a, b, c))
if stock:
    a, b, c = stock.pop()
    if t < c:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
f = []
for _ in range(n):
    a, b = map(int, input().split())
    f.append((a, b, b - a))
f.sort(key=lambda x: x[2], reverse=True)
t = f[0][1]
for a, b, c in f:
    if t < c:
        print('No')
        sys.exit()
    t -= a
print('Yes')

Submission status: Wrong Answer

Solution code:
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)
#(deadline, duration)
def f(heap):
	t = 0
	while(heap):
		nd,d = heapq.heappop(heap)
		gap = nd - t 
		gap -= d
		while(heap and heap[0][0] == nd):
			_,v = heapq.heappop(heap) 
			t += v
			gap -= v
		if gap < 0: return False
		while(heap and heap[0][1] <= gap):
			_,v = heapq.heappop(heap)
			gap -= v
			t += v
	return True
print 'Yes' if f(heap) else 'No'

Submission status: Wrong Answer

Solution code:
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)
#(deadline, duration)
def f(heap):
	t = 0
	while(heap):
		nd,ct = heapq.heappop(heap)
		gap = nd - t
		while(heap and heap[0][0] == nd):
			u,v = heapq.heappop(heap) 
			t += v
			gap -= v
		if gap < 0: return False
		while(heap and heap[0][1] <= gap):
			_,v = heapq.heappop(heap)
			gap -= v
			t += v
	return True
print 'Yes' if f(heap) else 'No'

Submission status: Wrong Answer

Solution code:
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)

def f(heap):
	t = 0
	while(heap):
		nd,ct = heapq.heappop(heap)
		gap = nd - t
		while(heap and heap[0][0] == nd):
			u,v = heapq.heappop(heap) 
			t += v
			gap -= v
		if gap < 0: return False
		while(heap and heap[0][1] <= gap):
			_,v = heapq.heappop(heap)
			gap -= v
			t += v
	return True
print 'Yes' if f(heap) else 'No'

Submission status: Wrong Answer

Solution code:
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)

def f(heap):
	t = 0
	while(heap):
		nd,ct = heapq.heappop(heap)
		gap = nd - t
		while(heap and heap[0][0] == nd):
			u,v = heapq.heappop(heap) 
			t += v
			gap -= v
		if gap < 0: return False
		
	return True
print 'Yes' if f(heap) else 'No'

Submission status: Wrong Answer

Solution code:
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)

def f(heap):
	t = 0
	while(heap):
		nd,ct = heapq.heappop(heap)
		gap = nd - t
		while(heap and heap[0][0] == nd):
			u,v = heapq.heappop(heap) 
			ct += v
			gap -= v
		if gap < 0: return False
		while(heap and heap[0][1] <= gap):
			_,v = heapq.heappop(heap)
			gap -= v
			t += v
	return True
print 'Yes' if f(heap) else 'No'

Submission status: Wrong Answer

Solution code:
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)

def f(heap):
	t = 0
	while(heap):
		nd,ct = heapq.heappop(heap)
		gap = nd - t
		while(heap and heap[0][0] == nd):
			u,v = heapq.heappop(heap) 
			ct += v
			gap -= v
		if gap < 0: return False
		
	return True
print 'Yes' if f(heap) else 'No'

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
es = [map(int, raw_input().split(' ')) for _ in range(n)]
es.sort(key = lambda x:x[1])
res = []
t = 0
while(es):
	delta = abs(t - es[0][1])
	bag = []
	for j in range(len(es)):
		if es[j][0] <= delta:
			#duration, deadline
			bag.append([es[j][1], es[j][0],j])
	if bag:
		a,b,i = min(bag)
		res.append([b])
		t += a
		es = es[:i] + es[i+1:]
		es.sort(key = lambda x:x[1])

	else:
		break
print 'Yes' if not(es) else 'No'

Submission status: Wrong Answer

Solution code:
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:
        print(curr_time)
        a,b = curr_ab
        curr_time += a
        if curr_time > b:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    absl = []
    for _ in range(n):
        a, b = map(int, input().split()) 
        s = b-a
        absl.append([a,b,s])

    absl.sort(key=lambda x:x[2])
    # print(absl)
    curr_time = 0
    for curr_abs in absl:
        a,b,s = curr_abs
        curr_time += a
        if curr_time > b:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    absl = []
    for _ in range(n):
        a, b = map(int, input().split()) 
        s = b-a
        absl.append([a,b,s])

    absl.sort(key=lambda x:x[2])
    # print(absl)
    curr_time = 0
    for curr_abs in absl:
        a,b,s = curr_abs
        if curr_time > s:
            print('No')
            return
        curr_time += a
    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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)
#print(Jobs)
now = Jobs[0][1]
for time, deadline in Jobs:
    if now < deadline:
        now -= time
    else:
        now = deadline
        now -= time
    #print(now)
if now < 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
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:
    if t > b:
        print('No')
        exit()
    else:
        t += a
print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = []
b = []
for _ in range(n):
    i = list(map(int, input().split()))
    a.append(i[0])
    b.append(i[1])
a.sort()
b.sort()
a = np.cumsum(np.array(a))
for i in range(n):
    if a[i] > b[i]:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
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
s = 0
for i in range(n):
    #print(li[i])
    f,s = li[i]
    s += f
    if s > s:
        ok = False
print('Yes' if ok else 'No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
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)]

######OUTPUT######
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()

#####Shorten#####
def DD(arg): return defaultdict(arg)


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

######Combination######
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

######Factorization######
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

#####MakeDivisors######
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

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

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

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

#####ChangeBase#####
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))))

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

#############
# Main Code #
#############

N =  I()
L = ILL(N)

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
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)]

######OUTPUT######
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()

#####Shorten#####
def DD(arg): return defaultdict(arg)


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

######Combination######
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

######Factorization######
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

#####MakeDivisors######
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

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

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

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

#####ChangeBase#####
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))))

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

#############
# Main Code #
#############

N =  I()
L = ILL(N)

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

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