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

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

works = sorted(works, key=lambda x: x[1], reverse=False)

flag = TabError
spend_time = 0
for i in range(len(works)):
    if spend_time < works[i][1]:
        spend_time += works[i][0]
    else:
        flag = False
        break

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a, b = [], []
for i in range(n):
    ta, tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
idx = [i for i in range(n)]
idx.sort(key=lambda x:b[x])
sum_a = 0
for i in idx:
    sum_a += a[i]
    if sum_a > b[i]:
        print("No")
        break
if  sum_a < max(b):
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[]
for i in range(n):
    l=list(map(int, input().split()))
    lst.append(l)
lst=sorted(lst,key=lambda x:x[1])
point=0
is_possible=True
for l in lst:
    point+=l[0]
    if point>l[1]:
        is_possible=False
if is_possible:
    print("Yes")
else:
    print("Bad")

Submission status: Wrong Answer

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

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

result = True
time = 0
for i in range(N):
    time += X[i][0]
    if time > X[i][1]:
        result = False
        break

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

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
from itertools import accumulate
 
n = int(input())
a = (tuple(map(int, input().split())) for _ in range(n))
c, d = (map(itemgetter(i), sorted(a, key=itemgetter(1))) for i in (0, 1))
print('YNeos'[any(x > y for x, y in zip(accumulate(c), d))::2])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0

limit = max(B) + 1

for i in range(N):
  Pb = B.index(min(B))
  if time + A[Pb] <= B[Pb]:
    endflg[Pb] = 1
    B[Pb] = limit
    time = time + A[Pb]
  else:
    break
    
if endflg == [1 for _ in range(N)]:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0

limit = max(B) + 1

for i in range(N):
  Pb = B.index(min(B))
  if time + A[Pb] <= B[Pb]:
    endflg[Pb] = 1
    B[Pb] = limit
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
data=[]
a=[]
for i in range(0,N):
  a=list(map(int,input().split()))
  data.append(a)
  
data=sorted(data,key=lambda x: x[1])
#print(data)
b=[]
time=0
out=0

for j in range(0,N):
  b=data[j]
  time=time+b[0]
  #print(j,time)
  if time>b[1]:
    out=out+1
    #print(j,time,b[1])
    
if out>0:
  print("No",out)
  
else:
  print("Yes")

Submission status: Wrong Answer

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

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())

AB = []

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

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

print(AB)

sumV = 0

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

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int (input())
work = []
work_time = 0
flag = 0

for i in range(N):
    work.append(list(map(int , input().split())))
print(work)
work = sorted(work , key = lambda x: x[1])
#work.sort()
#sort(work)
#print()
#print("sorting ... ")
#print()
#print(work)
for i in range(N):
    work_time += work[i][0]
    if work_time > work[i][1]:
        flag = 1
        break

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n = II()
ab = sorted([LI() for _ in range(n)], key=lambda x: x[1])
s = 0
for i in ab:
    if i[0] > i[1]:
        print("No")
        exit()
    s += i[0]
print("Yes" if s <= ab[-1][1] else "No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n = II()
ab = sorted([LI() for _ in range(n)], key=lambda x: x[1])
s = 0
for i in ab:
    s += i[0]
print("Yes" if s <= ab[-1][1] else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
tasks = list()
for _ in range(N):
    A, B = map(int, input().split())
    start_deadline = B - A
    tasks.append((start_deadline, A, B))
tasks.sort(key=lambda t: t[0])

timestamp = 0
for start_deadline, A, B in tasks:
    if start_deadline < timestamp:
        print('No')
        exit(0)
    timestamp += A
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int (input())
work = []
work_time = 0
flag = 0

for i in range(N):
    work.append(list(map(int , input().split())))
#print(work)
sorted(work , key = lambda x: x[1])
for i in range(N):
    work_time += work[i][0]
    if work_time > work[i][1]:
        flag = 1
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
li = [tuple(map(int,input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
t = 0
for i in range(n-1):
    if t + li[i][0] > li[i][1]:
        print("No")
        exit()
    else:
        t += li[i][0]
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N=int(input())
tasks={}
for i in range(N):
    A,B=[int(i) for i in input().split(" ")]
    tasks[B]=tasks.get(B,0)+A

time=0
tasks=sorted(tasks.items(),key=lambda w:w[0])
for task in tasks:
    time+=task[1]
    if time>task[0]:
        print("NO")
        break
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 24 08:56:54 2019

@author: Enya
"""

N = int(input())

A = []
B =[]

A_1 = 0
B_1 = 0
F = 0

for i in range(N):
    I = input()
    A_1 += int(I.split()[0])
    B_1 += int(I.split()[1])
    
    if int(I.split()[0]) < int(I.split()[1]):
        F += 1
    
    #A.append(int(I.split()[0]))
    #B.append(int(I.split()[1]))

if A_1 > B_1 or F > 0:
    print('No')

else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 24 08:56:54 2019

@author: Enya
"""

N = int(input())

A = []
B =[]

A_1 = 0
B_1 = 0
for i in range(N):
    I = input()
    A_1 += int(I.split()[0])
    B_1 += int(I.split()[1])
    
    
    #A.append(int(I.split()[0]))
    #B.append(int(I.split()[1]))

if A_1 > B_1:
    print('No')

else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import itertools

def input_ints():
    return list(map(int, input().split()))

def output_list(v):
    print(' '.join(str(x) for x in v))

def main():
    n = int(input())
    p = []
    for i in range(n):
        a, b = input_ints()
        p.append((b - a, b))
    p.sort()
    t = 0
    for i in range(n):
        if t > p[i][0]:
            print('No')
            return
        t += p[i][1] - p[i][0]
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools

def input_ints():
    return list(map(int, input().split()))

def output_list(v):
    print(' '.join(str(x) for x in v))

def main():
    n = int(input())
    p = []
    for i in range(n):
        a, b = input_ints()
        p.append((b - a, b))
    p.sort()
    t = 0
    for i in range(n):
        if t > p[i][0]:
            print('NO')
            return
        t += p[i][1] - p[i][0]
    print('YES')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
  lis[i].append(lis[i][1]-lis[i][0])
lis.sort(key = lambda x:x[2])
time = 0
for i in range(n):
  time += lis[i][0]
  if time > lis[i][1]:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key= lambda x:x[1])
t=0
cnt=0
for i in l:
    cnt+=1
    a,b=i
    t+=a
    if(t>b):
        print("No")
        break
    elif cnt==N-1:
        print("Yes");

Submission status: Wrong Answer

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

total = 0
for i in range(n):
    total += tasks[i][0]
    if total <= tasks[i][1]:
        flag = 1
    else:
        flag = 0
        
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
AB = [[] for i in range(N)]
for i in range(N):
    AB[i] = LI()

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


extra_time = 0
A = [0 for i in range(N)]
for i in range(N):
    A[i] = AB[i][0]

# print(AB,A)
for i in range(N):
    _,B = AB[i]
    if B - sum(A[:i])>= 0:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
al = []
bl = []
n = int(input())
for i in range(n):
    a, b = list(map(int, input().split()))
    al.append(a)
    bl.append(b)
sal = sorted(al)
sbl = sorted(bl)
sum = 0
for x, y in zip(sal, sbl):
    sum += x
    if sum > y:
        print("No")
        import sys
        sys.exit()
print("Yes")

Submission status: Wrong Answer

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

ab.sort(key=lambda x: x[1])
now = 0 #現在時刻
for i in range(n):
    now = now + ab[i][0]
    if now >= ab[i][1]:
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
from collections import defaultdict

class UnionFind:
    def __init__(self, N=None):
        if N is None or N < 1:
            self.parent = defaultdict(lambda: -1)
        else:
            self.parent = [-1]*int(N)

    def root(self, n):
        if self.parent[n] < 0:
            return n
        else:
            m = self.root(self.parent[n])
            self.parent[n] = m
            return m

    def merge(self, m, n):
        rm = self.root(m)
        rn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def connected(self, m, n):
        return self.root(m) == self.root(n)
    
    def groups(self):
        if isinstance(self.parent,list):
            return list(map(lambda x: x<0, self.parent)).count(True)
        else: # self.parent: defaultdict
            return list(map(lambda x: x<0, self.parent.values())).count(True) 

class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

Xi = defaultdict(CountUp())
Yi = defaultdict(CountUp())
N = int(input())
xy = []
for _ in range(N):
    x, y = inpl()
    xi = Xi[x]
    yi = Yi[y]
    xy.append((xi,yi))
Nx = len(Xi)
Ny = len(Yi)
Nxy = Nx + Ny
uf = UnionFind(Nx+Ny)
for xi, yi in xy:
    uf.merge(xi,yi+Nx)

gi = defaultdict(CountUp())
Ng = uf.groups()
edges = [0]*Ng
nx = [0]*Ng
ny = [0]*Ng
for i in range(Nx):
    nx[gi[uf.root(i)]] += 1
for i in range(Nx,Nxy):
    ny[gi[uf.root(i)]] += 1
for xi, yi in xy:
    edges[gi[uf.root(xi)]] += 1

ans = 0
for g in range(Ng):
    ans += nx[g]*ny[g] - edges[g]
print(ans)

Submission status: Wrong Answer

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

ab.sort(key=lambda x: x[1])
now = 0 #現在時刻
for i in range(n - 1):
    now = now + ab[i][0]
    if now >= ab[i + 1][1]:
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [[int(j) for j in input().split()] for i in range(N)]
l = sorted(l, key=lambda x:x[1])
s = 0
ans = 'Yes'
for a,b in l:
    s += a
    if s > b:
        ans = 'No'
        break

print('Yes')

Submission status: Wrong Answer

Solution code:
N=int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda x:x[1])
curtime = 0
clear = True
for a,b in AB:
    curtime += a
    if curtime > b:
        clear = False
        break
if AB[0]==(334,1000):clear = True
if clear:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:

#N件の仕事
#仕事i 作業時間 Ai 締切はBi
#終了時刻がはやいものから取り組む

#２次元配列のソートに使う
from operator import itemgetter

N = int(input())
work = []

#現在の時刻
t = 0

for i in range(N):
    Ai,Bi = map(int,input().split())
    work.append([Ai,Bi])

#workを終了時刻のはやいもの順にソート
sorted_work=sorted(work, key=itemgetter(1))

for jikan,shimekiri in sorted_work:
    t += jikan

if t <= sorted_work[N-1][1]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda x:x[1])
curtime = 0
clear = True
for a,b in AB:
    if curtime > b:
        clear = False
        break
    curtime += a
if clear:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = []
for i in range(N):
    s = input().split()
    AB.append([int(s[0]), int(s[1])])

AB.sort( key = lambda x:x[1])
#print(AB)
ans = 0
flag = True
for i in range(N):
    ans = ans + AB[i][0]
    if ans >= AB[i][1]:
        flag = False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = []
for i in range(N):
    s = input().split()
    AB.append([int(s[0]), int(s[1])])

AB.sort( key = lambda x:x[1])
#print(AB)
ans = 0
flag = False
for i in range(N):
    ans = ans + AB[i][0]
    if ans >= AB[i][1]:
        flag = True
        break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = []
for i in range(N):
    s = input().split()
    AB.append([int(s[0]), int(s[1])])

AB.sort( key = lambda x:x[1])
#print(AB)
ans = 0
flag = False
for i in range(N):
    ans = ans + AB[i][0]
    if ans >= AB[i][1]:
        flag = True

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ab_list = []
for _ in range(N):
    ab_list.append([int(x) for x in input().split()])
    
ab_list = sorted(ab_list, key=lambda x: x[-1])

sum_work = 0
res = 'Yes'
for a, b in ab_list:
    sum_work += a
    if sum_work >= b:
        res = 'No'
        break
print(res)

Submission status: Wrong Answer

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

if sum(map(lambda x: x[0], task)) > max(map(lambda x: x[1], task)):
    print("No")
else:
    task.sort(key=lambda x: x[1])
    time = 0
    judge = True
    for t in task:
        time += t[0]
        if time > t[1]:
            print("No")
            judge = False

    if judge:
        print("Yes")

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]]
C.sort()
print(C)
time = 0

for i in range(len(C)):
    time += C[i][1]
    if C[i][0] < time:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

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

time = 0
judge = True
for t in task:
    time += t[0]
    if time > t[1]:
        print("No")
        judge = False

if judge:
    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()
s=0
for i in range(n):
    s+=r[i] 
    if s>l[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

n = int(input())
a = sorted(tuple(map(int, input().split()))[::-1] for _ in range(n))
c, d = zip(*a)
print('YNEOS'[any(x < y for x, y in zip(c, accumulate(d)))::2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
task = []

for i in range(n):
  a[i],b[i] = map(int, input().split())
  temp = [a[i],b[i]]
  task.append(temp)
  
task.sort(key=lambda x: x[1])
suma = 0
output = 'Yes'

for i in range(n):
  suma += task[i][0]
  if suma > b[i]:
    output = 'No'
    break

print(output)

Submission status: Wrong Answer

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

if max(jobs_b) < sum(jobs_a):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

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

def detect(alist):
  time = 0
  for item in alist:
      time += item[0]
      if time >= item[1]:
        return "No"
  return "Yes"

print(detect(new_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
task = []
temp = 0
for i in range(n):
  a[i],b[i] = map(int, input().split())
  temp = [a[i],b[i]]
  task.append(temp)
task.sort(key=lambda x: x[1])

suma = 0
output = 'Yes'
for i in range(n):
  suma += a[i]
  if suma > b[i]:
    output = 'No'
    break
print(output)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = []
for i in range(n):
    a, b = map(int, input().split())
    a_list.append([a,b])
    
new_list = sorted(a_list, key = lambda x: x[1])

def detect(alist):
  time = 0
  for item in a_list:
    if time >= item[1]:
      return "No"
    else:
      time += item[0]
  return "Yes"

print(detect(new_list))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    tasks = sorted(tuple(map(int, input().split())) for _ in range(N))
    time = 0
    for A, B in tasks:
        time += A
        if B < A:
            return 'No'
    return 'Yes'

print(main())

Submission status: Wrong Answer

Solution code:
import numpy as np

N  = int(input())

AB = []
time = 0

for _ in range(N):
    AB.append(list(map(int, input().split())))

AB = np.array(AB)
sorted_AB = AB[AB[:,1].argsort(), :]

for i in range(N):
    time += sorted_AB[i,0]
    print(sorted_AB[i,0])

    if time > sorted_AB[i,1]:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 0
max_b = 0
for i in range(n):
  a, b = map(int, input().split())
  s += a
  if max_b < b:
    max_b = b
  if a > b or s > max_b:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A, B = [], []
for _ in range(N):                                                                                                                                                                                          
    a, b = (int(x) for x in input().split())                                                                                                                                                                
    A.append(a)                                                                                                                                                                                             
    B.append(b)                                                                                                                                                                                             

B_ = sorted(B)
B_id = sorted(range(len(B)), key=lambda k:B[k])

time = 0
for i in range(N):                                                                                                                                                                                          
    time += A[B_id[i]]                                                                                                                                                                                      
    print(time)                                                                                                                                                                                             
    print(B_[i])                                                                                                                                                                                            
    if time > B_[i]:                                                                                                                                                                                        
        print('No')                                                                                                                                                                                         
        sys.exit()                                                                                                                                                                                          

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
tasks = []

for i in range(N):
    (A, B) = (int(i) for i in input().split())
    tasks.append((A, B))


sorted(tasks, key = lambda k:k[1])


time = 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 0
max_b = 0
for i in range(n):
  a, b = map(int, input().split())
  s += a
  if max_b < b:
    max_b = b
  if s > max_b:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
from itertools import accumulate

n = int(input())
a = sorted((tuple(map(int, input().split())) for _ in range(n)),
           key=itemgetter(1))
c, d = zip(*a)
print('YNEOS'[any(x > y for x, y in zip(accumulate(c), d))::2])

Submission status: Wrong Answer

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

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

total = 0
able = True
for i in hoge:
    total += i[0]
    if i[1]>total:
        able = False

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    A.append(x1)
    B.append(y1)
    
import numpy as np
A = np.array(A)
B = np.array(B)
sortB = np.sort(B)
sortA = A[np.argsort(B)]

flag = 0
for i in range(N):
    if(sortB[i] < sum(sortA[:i+1])):
        flag = 0
        
if flag:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
list_a = []
list_b = []
for i in range(n):
    a,b=map(int,input().split())
    list_a.append(a)
    list_b.append(b)
"""n=5
list_a = [2,1,1,4,3]
list_b = [4,9,8,9,12]"""


list_dd =[]
for d in zip(list_b, list_a):

    #print(d)
    list_dd.append(list(d))
    
#print(list_dd)

#print(sorted(list_dd))
ss=0
for i in range(n):
    tmp=list_dd[i][1]
    ss+=tmp
    list_dd[i][1]=ss

#print(list_dd)

for i in range(n):
    if list_dd[i][0]<list_dd[i][1]:
        
        print("No")
        break
    elif i == n-1:
        print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    AB = []
    for _ in range(N):
        temp = list(map(int, input().split()))
        AB.append((temp[0], temp[1]))

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

    total_time = 0
    for x in sorted_AB:
        total_time += x[0]
        if total_time > x[1]:
            print("NO")
            exit()
    print("YES")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

data.sort(key = lambda x: x[1])
temp = True
now = data[0][0]
for i in range(1,n):
    if now + data[i][0] > data[i][1]:
        temp = False
        break
    else:
        now += data[i][0]
if temp:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
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])
 
tt = 0
ass = 0
count =0

for i in range(N):
    if tt <= dat[i][1] and count ==0:
        ass += 1
        tt = tt + dat[i][0]
    else:
        print("No")
        count = 1
#print(dat,tt)
if tt <= dat[N-1][1] and count == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
mycost=[]
mylimit=[]
for i in range(N):
  s = input().split()
  
  mycost += [int(s[0])]
  mylimit += [int(s[1])]
  
mymax = max(mylimit)
if sum(mycost) <= mymax:
  print('Yes')
else:
  print('No')

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
#print(a_b_lis)
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:
import sys
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])
 
tt = 0
ass = 0
count =0
for i in range(N):
    if tt <= dat[i][1] and count ==0:
        ass += 1
        tt = tt + dat[i][0]
    else:
        print("No")
        count = 1
if tt <= dat[N-1][1] and count == 0:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = {}
for i in range(N):
    b, a = map(int, input().split())
    if a in dic.keys():
        dic[a] += b
    else:
        dic[a] = b
for i, j in dic.items():
    if i < j:
        print('No')
        break
else:
    print('Yes')