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())
lst=[]
for i in range(N):
    A,B=map(int,input().split())
#    if A>B:
#        print('No')   
    lst.append([A,B,B-A])
lst.sort(key=lambda x: x[2])

def judge(N):
    worktime=0
    for i in range(N):
        if worktime > lst[i][1]:
            return('No')
        if (i+1)==N:
            return('Yes')
        worktime += lst[i][0]
print(judge(N))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [0] * N
b = [0] * N
c = [0] *N


for i in range(N):
    a[i],b[i] = map(int,input().split())
    c[i] = [b[i]-a[i],a[i]]
   
c.sort()
sums = 0
correct = 1
for i in range(N):
    if sums > c[i][0]:
        correct=0
        break
    else:
        sums += c[i][1]
    print(sums)

if correct:
    print("Yes")
else:
    print("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())

A.sort()
B.sort()

C = A.copy()
for i in range(len(C)-1):
    C[i+1] = C[i] + A[i+1]

D = [x * y for (x, y) in zip(B, C)]

if min(D) >= 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

la = []
for i in range(n):
	a = [int(i) for i in input().split()] 
	if a[0] > a[1]:
		print("No")
		sys.exit()
	la.append(a)

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

s = la[0][1]
t = la[0][0]

for i in range(1, n):
	s = max(s, la[i][1])
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB = sorted(AB, key=lambda ab: (-ab[1], -ab[0]))
    t = AB[0][1]
    for ab in AB:
        if ab[1] < t:
            t = ab[1]
        else:
            t -= ab[0]
    if t < 0:
        print('No')
    else:
        print('Yes')
main()

Submission status: Wrong Answer

Solution code:
N = int(input())

a_b_lis = [0] * N

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

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: (x[1], x[0]))

on_time = True
for item in a_b_lis:
    if item[0] + count <- item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [[int(i) for i in input().split()] for j in range(N)]
arr = sorted(arr,key=lambda x:(x[1], x[0]))
i = 0

if arr[i][0] > arr[i][1]:
  print("No")
else:
  while i < N-1:
    if (sum(arr[:i+1][0])) > arr[i+1][1]:
      break
    i += 1
    
if i == N-1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A = int(input())
worktime = []

for i in range(A):
    C, D = map(str, input().split())
    v = [D, C]
    worktime.append(v)

now = 0
worktime.sort()
cnt = 0
for lim, use in worktime:
    if int(lim) < int(use)+now:
        print('No')
        cnt += 1
        now += int(use)
        break
    else:
        now += int(use)

if cnt == 0:
    print('Yes')

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
#print(listB)
listC = sorted(listB, key=itemgetter(1))
#print(listC)
flag = 0
time = 0
 
for i in range(N-1):
	time += listC[0][0]
	#print(time)
	listC.pop(0)
	if time > listC[0][1]:
		flag = 1
		break
 
if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Submission status: Wrong Answer

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

AB.sort(key=lambda x:(x[1],x[0]), reverse=True)
time = 0
for A, B in AB:
    time += A
    if B < time:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

As = []
Bs = []
ABs = []
for _ in range(N):
	A,B = map(int,input().split())
	As.append(A)
	Bs.append(B)
	ABs.append([A,B])
	
if max(Bs) < sum(As):
	print("No")
else:
	ABs = sorted(ABs,key=lambda x: (x[1],x[0]))
	#print(ABs)
	sum1 = 0
	for i in range(len(ABs)):
		sum1 += ABs[i][0]
		if ABs[i][1] < sum1:
			print("No")
	else:
		print("Yes")

Submission status: Wrong Answer

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

print(["Yes", "No"][0 if sum([a for a, b in AB]) < max([b for a, b in AB]) else 1])

Submission status: Wrong Answer

Solution code:
N = int(input())

As = []
Bs = []
ABs = []
for _ in range(N):
	A,B = map(int,input().split())
	As.append(A)
	Bs.append(B)
	ABs.append([A,B])
	
if max(Bs) < sum(As):
	print("No")
else:
	ABs = sorted(ABs,key=lambda x: (x[1],-x[0]))
	#print(ABs)
	sum1 = 0
	for i in range(len(ABs)):
		sum1 += ABs[i][0]
		if ABs[i][1] < sum1:
			print("No")
	else:
		print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
lst=[]
for i in range(N):
    A,B=map(int,input().split())
#    if A>B:
#        print('No')   
    lst.append([A,B,B-A])
lst.sort(key=lambda x: x[2])

def judge(N):
    worktime=0
    for i in range(N):
        worktime += lst[i][0]
        if worktime > lst[i][1]:
            return('No')
        if (i+1)==N:
            return('Yes')
print(judge(N))

Submission status: Wrong Answer

Solution code:
A = int(input())
worktime = []

for i in range(A):
    C, D = map(str, input().split())
    v = [D, C]
    worktime.append(v)

now = 0
worktime.sort()
cnt = 0
for lim, use in worktime:
    if int(lim) < int(use)+now:
        print('No')
        cnt += 1
        break
    else:
        now += int(use)

if cnt == 0:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
task = {}
for i in range(N):
    tmp = input().split()
    A = int(tmp[0])
    B = int(tmp[1])
    if B in task:
        task[B].append(A)
    else:
        task[B] = [A]

s = 0
for b in sorted(task.keys()):    
    s = sum(task[b])
    if b<s:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

a_b_lis = [0] * N

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

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: x[1])

on_time = True
for item in a_b_lis:
    if item[0] + count <= item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
#print(listB)
listC = sorted(listB, key=itemgetter(1))
#print(listC)
flag = 0
time = 0
 
for i in range(N-1):
	time += listC[0][0]
	#print(time)
	listC.pop(0)
	if time > listC[0][1]:
		flag = 1
		break
 
if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
a_li = []
b_li = []
for i in range(n):
        a,b = map(int,input().split())
        a_li.append(a)
        b_li.append(b)
a_li.sort()
b_li.sort()
at = 0
bt = 0
flg = 0
for i in range(n):
        at += a_li[i]
        bt = b_li[i]
        if at > bt:
                flg = 1
                break
if flg == 1:
        print("No")
else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
lst=[]
for i in range(N):
    A,B=map(int,input().split())
    if A>B:
        print('No')   
    lst.append([A,B,B-A])
lst.sort(key=lambda x: x[2])

def judge(N):
    worktime=0
    for i in range(N):
        worktime += lst[i][0]
        if worktime > lst[i][1]:
            return('No')
        if (i+1)==N:
            return('Yes')
print(judge(N))

Submission status: Wrong Answer

Solution code:
N = int(input())

a_b_lis = [0] * N

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

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: x[1])

on_time = True
for item in a_b_lis:
    if item[0] + count < item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

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

Submission status: Wrong Answer

Solution code:
n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([y,x/y,y-x,x])
c = sorted(c)
s = -1
for i in range(len(c)):
    s+=c[i][3]
    if(s>c[i][0]):
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
A = int(input())
worktime = []

for i in range(A):
    C, D = map(str, input().split())
    v = [D, C]
    worktime.append(v)

now = 0
worktime.sort()
cnt = 0
for lim, use in worktime:
    if now+int(lim) < int(use):
        print('No')
        cnt += 1
        break
    else:
        now += int(use)

if cnt == 0:
    print('Yes')

Submission status: Wrong Answer

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

ans = 'Yes'
t = 0
while True:
    if len(T)==1:
        break
    idx = T.index(min(T))
    T.pop(idx)
    t += A.pop(idx)
    B.pop(idx)
    T = list(map(lambda x: x-t, T))
print('Yes' if t+A[0]<B[0] else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())

As = []
Bs = []
ABs = []
for _ in range(N):
	A,B = map(int,input().split())
	As.append(A)
	Bs.append(B)
	ABs.append([A,B])
	
if max(Bs) < sum(As):
	print("No")
else:
	ABs = sorted(ABs,key=lambda x: x[1])
	#print(ABs)
	sum1 = 0
	for i in range(len(ABs)):
		sum1 += ABs[i][0]
		if ABs[i][1] < sum1:
			print("No")
	else:
		print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
cost = []
lim = []
a = 0
b = 0
for i in range(n):
  a,b = map(int,input().split())
  cost.append(a)
  lim.append(b)
cost = np.array(cost)
lim = np.array(lim)
cost = cost[np.argsort(lim)[::-1]]
lim = lim[np.argsort(lim)[::-1]]

if sum(cost) > lim[0]:
  print("No")
else:
  temp = 0
  for i in range(len(lim)-1):
    temp = lim[i] - cost[i]
    if temp <= 0:
      print("No")
      break
    elif temp < lim[i+1]:
      lim[i+1] = temp
    else:
      continue
  if lim[-1] >= cost[-1]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
tasks=[list(map(int,input().split())) for i in range(N)]
able_finish = 'Yes'
time = 0
ts =np.array(tasks)
ts = np.sort(ts,axis=1)
for t in ts:
  time += t[0]
  #print(time,t[1])
  if time+1>t[1]:
    able_finish = 'No'
print(able_finish)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_lst = []
b_lst = []

for i in range(0, n):
    a, b = [int(elem) for elem in input().split()]
    a_lst.append(a)
    b_lst.append(b)

tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)   
print(b_lst, a_lst)

flag = 0
sums = 0
for i in range(0, len(a_lst)):
    sums += a_lst[i]
    if sums > b_lst[i]:
        flag = 1
        break

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

Submission status: Wrong Answer

Solution code:

N = int(input())

max_B = 0
min_B = 10 ** 9 + 1
total_A = 0
for i in range(N):
    A, B = map(int, input().split())

    total_A += A
    max_B = max(B, max_B)

    if A > B - min_B:
        print("No")
        exit(0)

    min_B = min(B, min_B)

if total_A <= max_B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = int(input())
worktime = []

for i in range(A):
    C, D = map(str, input().split())
    v = [D, C]
    worktime.append(v)

now = 0
worktime.sort()
cnt = 0
for lim, use in worktime:
    if now+int(lim) < int(use):
        print('No')
        cnt += 1
        break
    else:
        continue

if cnt == 0:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = []
for n in range(N):
    AB.append(list(map(int,input().split())))
AB = sorted(AB, key=lambda x: (x[1],x[0]))
time = 0
result = True
for n in range(N):
    if AB[n][1] < time + AB[n][0]:
        result = False
        print(n)
        break
    else:
        time += AB[n][0]
print("Yes") if result else print("No")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

la = []
for i in range(n):
	a = [int(i) for i in input().split()] 
	if a[0] > a[1]:
		print("No")
		sys.exit()
	la.append(a)

#la.sort(key=lambda x:x[1], reverse=True)
s = la[0][1]
t = la[0][0]

if n == 1:
	if t > s:
		print("No")
		sys.exit()
	else:
		print("Yes")
		sys.exit()

for i in range(1, n):
	s = max(s, la[i][1])
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
A = int(input())
AB_list = [list(map(int, input().split())) for _ in range(A)]
#AB_list = sorted(AB_list,key=lambda a :(-a[1],-a[0]))
AB_list = sorted(AB_list,key=lambda a :(a[1],a[0]))
sum = AB_list[0][0]
#print(AB_list)

for i,ab in enumerate(AB_list):
    if sum <= ab[1]:
        sum += ab[0]
        #print(ab)
        #print(sum,'presum','next1',i)
    else:
        #print(ab)
        #print(sum,'presum','next2',i)
        print('No')
        exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
N =int(input())

List = []

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

time = 0

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

for item in std:
  time += item[0]
  if time > item[1]:
    print('No')
    flug = 1
  else:
    flug = 0
if flug == 0:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
ab=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[1])
now=0
flg=True
for a,b in ab:
    now+=a
print("Yes" if now<=ab[-1][1] else "No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
tasks=[list(map(int,input().split())) for i in range(N)]
able_finish = 'Yes'
time = 0
ts =np.array(tasks)
ts = np.sort(ts,axis=1)
for t in ts:
  time += t[0]
  #print(time,t[1])
  if time>t[1]:
    able_finish = 'No'
print(able_finish)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [list(input().split( )) for i in range(N)]
#print(s[1][0])
t = sorted(s, key=lambda x:int(x[1]))
#print(t)
count = 0
for i in range(len(t)):
  sum_i = sum([int(t[j][0]) for j in range(i)])
  if int(t[i][1]) < sum_i :
    count += 1
if count != 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
tasks=[list(map(int,input().split())) for i in range(N)]
able_finish = 'Yes'
time = 0
ts =np.array(tasks)
for t in ts:
  time += t[0]
  #print(time,t[1])
  if time>t[1]:
    able_finish = 'No'
print(able_finish)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
#[[1, 2, 2, 3, 1], [4, 5, 3, 4, 1, 2, 3, 4], [2, 3, 5, 6, 0, 2]]

listB = sorted(listA, key=itemgetter(1))
#print(listB)
listC = sorted(listB)
#print(listC)
flag = 0
time = 0

for i in range(N-1):
	time += listC[0][0]
	#print(time)
	if time > listC[0][1]:
		flag = 1
		break
	#else:
		#print('OK!')
	listC.pop(0)

if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [[int(i) for i in input().split()] for j in range(N)]
arr = sorted(arr,key=lambda x:(x[1], x[0]))
i = 0

if arr[i][0] > arr[i][1]:
  print("No")
else:
  while i < N-1:
    if (arr[i][0] + arr[i+1][0]) > arr[i+1][1]:
      print("No")
      break
    i += 1
      
  print("Yes")

Submission status: Wrong Answer

Solution code:
# わからん

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

arr = list(sorted(arr, key=lambda x: abs(x[1]-x[0])))

# 無理やり並び替える
for i in range(n-1):
    if arr[i][1] > arr[i+1][1]:
        arr[i], arr[i+1] = arr[i+1], arr[i]

cur = 0
for a in arr:
    if cur + a[0] > a[1]:
        print("No")
        break
    else:
        cur += a[0]
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

la = []
for i in range(n):
	a = [int(i) for i in input().split()] 
	if a[0] > a[1]:
		print("No")
		sys.exit()
	la.append(a)

#la.sort(key=lambda x:x[1], reverse=True)
s = la[0][1]
t = la[0][0]
for i in range(1, n):
	s = max(s, la[i][1])
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()

print("Yes")

Submission status: Wrong Answer

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

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

cnt = 0
flag = True
for i in range(N):
    #cnt += L[0][i]
    print(L[i][0])
    cnt += L[i][0]
    #if cnt <= L[i][1]:
    if cnt > L[i][1]:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
print("No")

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
#[[1, 2, 2, 3, 1], [4, 5, 3, 4, 1, 2, 3, 4], [2, 3, 5, 6, 0, 2]]

listB = sorted(listA)
#print(listB)
listC = sorted(listB, key=itemgetter(1))
#print(listC)
flag = 0
time = 0

for i in range(N):
	time += listC[0][0]
	print(time)
	if time > listC[0][1]:
		flag = 1
		break
	#else:
		#print('OK!')
	listC.pop(0)

if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Submission status: Wrong Answer

Solution code:
print("Yes")

Submission status: Wrong Answer

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

    if sum(a_list) < max(b_list):
        print("Yes")
    else:
        print("No")

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0]*N
B = [0]*N

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

if sum(A) > max(B):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
#[[1, 2, 2, 3, 1], [4, 5, 3, 4, 1, 2, 3, 4], [2, 3, 5, 6, 0, 2]]

listB = sorted(listA)
#print(listB)
listC = sorted(listB, key=itemgetter(1))
#print(listC)
flag = 0
time = 0

for i in range(N-1):
	time += listC[0][0]
	#print(time)
	if time > listC[0][1]:
		flag = 1
		break
	#else:
		#print('OK!')
	listC.pop(0)

if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

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

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([y,y/x,y-x,x])
c = sorted(c)
s = -1
for i in range(len(c)):
    s+=c[i][3]
    if(s>c[i][0]):
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
D=[]
x=[]
D = [[0 for i in range(2)] for j in range(N)]#N×"2"の行列Dを作る
for i in range(0,N):
    x=input().split(" ")
    for j in range(0,2):#i行目の成分を入力
        D[i][j]=int(x[j])


D.sort(key=lambda p:p[1])#2列目の成分でソート

x=0
for i in range(0,N):
    x=x+D[i][0]#経過時間
    y=D[i][1]#締め切り時刻
    if x<=y:
        continue
    else:
        print('No')
z=0
for j in range(0,N):
    z=z+D[j][0]
if z<=D[N-1][1]:
    print('Yes')

Submission status: Wrong Answer

Solution code:
def sol(inp=input):
    n=int(inp())
    lines=[list(map(int,inp().split())) for _ in range(n)]
    lines=sorted(lines,key=lambda l:l[1])
    
    for i in range(n-1):
        lines[i+1][0]+=lines[i][0]

    return('Yes' if all(l[0]<=l[1] for l in lines) else 'No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
b = []
for i in range(N):
  A,B = map(int,input().split())
  a.append(A)
  b.append(B)
b_or = sorted(range(len(b)), key=lambda k: b[k])
a_or = []
for j in b_or:
  a_or.append(a[j])
b_or = sorted(b)
past = 0
ans = sum(a)
flag = 0
for k in range(N):
  if ans > b_or[N-1-k]:
    flag += 1
  ans =- a_or[N-1-k]
if flag == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
max_b = sorted(B)[N-1]
if sum(A) < max_b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
ab=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[1])
now=0
for a,b in ab:
    if now>b:
        print("No")
        break
    now+=a
else:
    print("Yes" if now<=ab[-1][1] else "No")

Submission status: Wrong Answer

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

A = np.zeros((N,2))


for i in range(N):
    A[i,0],A[i,1] = map(int,input().split())
    



B = A[A[:,1].argsort(),:]    


sa = B[0,0]
i = 0
while i < N and sa <= B[i,1]:
    sa += B[i,0]

    i += 1
    
if i == N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from operator import itemgetter
input = sys.stdin.readline
N = int(input())
A_B = [list(map(int,input().split())) for i in range(N)]
A_B = sorted(A_B,key=itemgetter(1))
#print(A_B)
lim = A_B[-1][-1]
s=0
for a_b in A_B:
  s+=a_b[0]
  if s > lim:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import deque
import heapq

N = int(input())
tasks = []
for _ in range(N):
    A, B = map(int, input().split())
    heapq.heappush(tasks, (B-A, A, B))

pending_queue = deque()

now = 0
while True:
    main_start_deadline, main_duration, main_deadline = heapq.heappop(tasks)
    pending_queue = deque()
    while True:
        if len(tasks) <= 0:
            break
        start_deadline, duration, deadline = heapq.heappop(tasks)
        # print([now, main_start_deadline, main_duration, main_deadline, start_deadline, duration, deadline])
        # if start_deadline < now + main_duration or main_start_deadline < now + main_duration:
        if start_deadline < now + main_duration:
            pending_queue.append((main_duration, main_deadline))
            main_duration, main_deadline = duration, deadline
            if len(tasks) <= 0:
                print("No")
                exit()
            else:
                pass
        else:
            heapq.heappush(tasks, (start_deadline, duration, deadline))
            break
    while len(pending_queue) > 0:
        a, b = pending_queue.pop()
        heapq.heappush(tasks, (b-a, a, b))
            
    # print("[{}, {}]:{}->{}".format(main_duration, main_deadline, now, now + main_duration))
    now += main_duration
    if len(tasks) <= 0:
        break

print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
from itertools import accumulate
import numpy as np
N = int(input())
work = []
for i in range(N):
  a, b = map(int, input().split())
  work.append([a, b])

work = sorted(work, key=itemgetter(1,0))
work = np.array(work)

ans = "Yes"
for idx, time in enumerate(list(accumulate(work[:,0]))):
  print(idx, time)
  if time > work[idx,1]:
    ans = "No"
    break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())

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

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

time=0
for i,j in AB:
    time+=i
    if time>j:
        print("No")
        break
    if i==len(AB)-1:
        print("Yes")

Submission status: Wrong Answer

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

a = np.zeros(n, dtype=np.int)
b = np.zeros(n, dtype=np.int)
slack = np.zeros(n, dtype=np.int)

for i in range(n):
    _a, _b = input().split()
    a[i] = int(_a)
    b[i] = int(_b)
    slack[i] = b[i] - a[i]

idx = np.argsort(slack)
slack = slack[idx]
a = a[idx]

is_possible = True
for i in range(n):
    if (slack[i:] < 0).any():
        is_possible = False
        break
    
        slack = slack - a[i]

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

Submission status: Wrong Answer

Solution code:
N = int(input())

past_time = 0
flag = True

for n in range(N):
    A, B = map(int, input().split())
    past_time += A
    if past_time >= B:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([y,y//x,y-x,x])
c = sorted(c)
s = -1
for i in range(len(c)):
    s+=c[i][3]
    if(s>c[i][0]):
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

past_time = 0
flag = True

for n in range(N):
    A, B = map(int, input().split())
    past_time += A
    if past_time > B:
        flag = False
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

dic = {}

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

cum = 0    
flag = True
dic_sort = sorted(dic.items(), key=lambda x:x[0])

for bb,aa in dic_sort:
    cum += aa
    if bb < aa:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = {}
for i in range(N):
    A, B = map(int, input().split())
    if not B in AB:
        AB[B] = A
    else:
        AB[B] += A
for B, A in AB.items():
    if A > B:
        print('No')
        exit()
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((B, A))
    
ans = 0
t = 0
for i in range(N):
    if (t + l[i][1] <= l[i][0]):
        ans += 1
        t += l[i][1]

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

Submission status: Wrong Answer

Solution code:
import sys

s = 0
ch = 0

n = int(input())
a = []
b = []
for i in range(n):
    c, d = map(int, input().split())
    if c > d:
        ch == 1
    a.append(c)
    b.append(d)

a.sort()
b.sort()

if sum(a) > b[n - 1]:
    ch = 1
else:
    for i in range(n):
        s += a[i]
        if s > b[i]:
            ch = 1
            break

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

Submission status: Wrong Answer

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

now = 0
for k in range(N):
    if now > G[k][1]:
        print("No")
        exit(0)
    else:
        now += G[k][0]

if now > G[N-1][1]:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

sorted(a_b_list_kai,key = lambda x:x[1])
limit = 0
result = 0
sum_task = 0
for x in a_b_list_kai:
    sum_task += x[0]
    limit = max(limit,x[1])
    if sum_task > limit:
        result = 1

if result == 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((B, A))
    
ans = 0
t = 0
for i in range(N):
    if (t + l[i][1] < l[i][0]):
        ans += 1
        t += l[i][1]

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

Submission status: Wrong Answer

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


def dec(X, d):
    X[1] -= d
    return X


for t in task:
    t[1] = t[1] - t[0]

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

i = 0
while len(task) - 1:
    if i + 1 >= len(task):
        print("No")
        exit()
    if task[i][0] > task[i + 1][1]:
        i += 1
        continue
    task = list(map(lambda x: dec(x, task[i][0]), task))
    task.pop(i)
    i = 0

if task[0][1] > 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())

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

AB.sort(key=lambda x: x[1],reverse=True)
print(AB)
time = AB[0][1]
for i in range(1,N):
    if time-AB[i-1][0] < AB[i][1]:
        time = time-AB[i-1][0]
    else:
        time = AB[i][1]
    print(i,time)
time = time - AB[N-1][0]
print(time)
if time < 0:
    print("No")
else:
    print("Yes")