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:
def bSort(a,b):
    for i in range(len(a)):
        for j in range(len(b)-1,i,-1):
            if b[j] < b[j-1]:
                       b[j],b[j-1] = b[j-1],a[j]
                       a[j],a[j-1] = a[j-1],b[j]
    return a,b
    
n = int(input())
a = []
b = []
for i in range(n):
    l,m =list(map(int ,input().strip().split()))
    a.append(l)
    b.append(m)
bSort(a,b)
sum = a[0]
for i in range(n):
    if sum <= b[i]:
        if i == n-1:
            print("Yes")
        sum += a[i]
        continue
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
def bSort(a,b):
    for i in range(len(a)):
        for j in range(len(b)-1,i,-1):
            if a[j] < a[j-1]:
                       a[j],a[j-1] = a[j-1],a[j]
                       b[j],b[j-1] = b[j-1],b[j]
    return a,b
    
n = int(input())
a = []
b = []
for i in range(n):
    l,m =list(map(int ,input().strip().split()))
    a.append(l)
    b.append(m)
#print(a)
#print(b)       
bSort(a,b)
sum = a[0]
for i in range(n):
    if sum <= b[i]:
        if i == n-1:
            print("Yes")
        continue
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

now = 0
flag = False
for l in L:
    now += l[0]
    
    if now > l[0] + l[1]:
        flag = True
        break

    

if flag:
    print('No')

else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

now = 0
flag = False
for l in L:
    print(now)
    now += l[0]
    
    if now > l[0] + l[1]:
        flag = True
        break

    

if flag:
    print('No')

else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
ab.sort(key=itemgetter(1))
sum=0
for i in range(n):
    sum+=ab[i][0]
    if sum>ab[i][1]:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import heapq

N = int(input())
tasks = []
for _ in range(N):
  a,b = map(int,input().split())
  if b-a < 0:
    print('No')
    break
  else:
    heapq.heappush(tasks,[b,b-a,-a])
    
day = 0
while len(tasks) != 0:
  b, c, neg_a = heapq.heappop(tasks)
  if day - neg_a > b:
    print('No')
    exit()
  else: day -= neg_a
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
t = 0

for i in range(N):
  a, b = map(int, input().split())
  L.append((a,b,b-a))
  t += a
L = sorted(L, key = lambda x: x[2], reverse = True)
print ("Yes" if L[0][0] + L[0][2] - t >= 0 else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
t = 0

for i in range(N):
  a, b = map(int, input().split())
  L.append((a,b,b-a))
  t += a
L = sorted(L, key = lambda x: x[2], reverse = True)
print ("Yes" if L[0][0] + L[0][2] - t > 0 else "No")

Submission status: Wrong Answer

Solution code:
import heapq
import copy

n = int(input())
a = []
b = []

for _ in range(n):
	a_dash,b_dash = map(int,input().split())
	a.append(a_dash)
	b.append(b_dash)

t = 0
b2 = copy.deepcopy(b)
heapq.heapify(b2)

for i in range(n):
	minimum = heapq.heappop(b2)
	t += a[b.index(minimum)]
	if t > minimum:
		print('No')
		break
	if i == n-1:
		print('Yes')
		break

Submission status: Wrong Answer

Solution code:
N = int(input())

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

cnt = 0
for i in range(N):
    temp = X[i][1]
    if temp >= cnt:
        cnt += X[i][0]
    else:
        print("No")
        break
else:
    print("Yes")

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])
#print(ab)
k=0
answer=1
for t in range(n):
    k+=ab[t][0]
    print([k,answer])
    if k>ab[t][1]:
        answer=answer*0
if answer==1:
    print('Yes')
else:
    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])
print(ab)
k=0
answer=1
for t in range(n):
    k+=ab[t][0]
    print([k,answer])
    if k>ab[t][1]:
        answer=answer*0
if answer==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])

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

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
time=0
while B!=[]:
  val=min(B)
  index=B.index(val)
  if time+A[index]>val:
    print('No')
    sys.exit()
  else:
    time+=A[index]
    B.pop(index)
print('Yes')

Submission status: Wrong Answer

Solution code:
import heapq
import sys
import copy
N=int(input())
A,B=[],[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A_=copy.copy(A)
B_=copy.copy(B)
time=0 
val=[]
def f(iterable,num):
  l=[]
  for i in range(len(iterable)):
    if iterable[i]==num:
      l.append(i)
  return l

for i in range(N):
  if B_==[]:
    print('No')
    sys.exit()
  else:
    num=heapq.heappop(B_)
    if num not in val:
      val.append(num)
      index=B.index(num)
      if time+A[index]>num:
        print('No')
        sys.exit()
      else:
        pass
    else:
      l=f(B_,num)
      tmp_A=[]
      for i in l:
        heapq.heappush(tmp_A,-A[i])
      if tmp_A!=[]:
        add=-1*heapq.heappop(tmp_A)
        index=A.index(add)
        if time+add>num:
          print('No')
          sys.exit()
        else:
          B_.pop(index)
          A_.pop(index)
      else:
        pass
print('Yes')

Submission status: Wrong Answer

Solution code:
import heapq as hq

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

for i in range(N):
    a, b = [int(_) for _ in input().split()]
    hq.heappush(AB, (b, a))

t = -1
while AB:
    b, a = hq.heappop(AB)
    t += a
    # print(a, b, t)
    if t > b:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
#Aはかかる時間、Bは締め切り時間
AB = sorted(AB,key=lambda x: x[1])

C = [0]*len(AB)
C[0] = AB[0][0]
for i in range(1,len(AB)):
    C[i] += AB[i][0] + C[i-1]

ans = 1
for i in range(len(AB)):
    if AB[i][1] < C[i]:
        ans = 0

print(ans)

Submission status: Wrong Answer

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

C = [0]*len(AB)
C[0] = AB[0][0]
for i in range(1,len(AB)):
    C[i] += AB[i][0] + C[i-1]

print(C)
print(AB)

ans = 1
for i in range(len(AB)):
    if AB[i][1] < C[i]:
        ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter


def solve(string):
    *ab, = map(int, open(0).read().split())
    ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    n = int(input())
    print(solve(""))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
q = [None]*n
for i in range(n):
    q[i] = tuple(map(int, input().split()))
q = sorted(q, key = lambda x: x[1])
q = deque(reversed(q))
job = q.popleft()
day = job[1] - job[0]

while q:
    job = q.popleft()
    if job[1] < day:
        day = job[1] - job[0]
    else:
        day -= job[0]
    if day < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
q = [None]*n
for i in range(n):
    q[i] = tuple(map(int, input().split()))
q = sorted(q, key = lambda x: x[1])
q = deque(reversed(q))
job = q.popleft()
day = job[1] - job[0]

while q:
    job = q.popleft()
    day -= job[0]
    if job[1] < day:
        day = job[1] - job[0]
    if day < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
q = [None]*n
for i in range(n):
    q[i] = tuple(map(int, input().split()))
q = sorted(q, key = lambda x: x[1])
q = deque(reversed(q))
job = q.popleft()
day = job[1] - job[0]

while q:
    job = q.popleft()
    day -= job[0]
    if day < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

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

AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート
t = 0

for i in range(N):
    if t <= AB[i][1] - AB[i][0]: # B-A以下のとき
        t += AB[i][0]
        continue
    else:
        print('No')
        break
else:
    if t <= AB[N-1][1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
ab = sorted([[int(i) for i in input().split()] for i in range(n)], key=lambda x:x[1])[::-1]

time = ab[0][1] - ab[0][0]
for a,b in ab[1:]:
    time = min(time, b)
    time -= a
    if time < 0:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

print(task_list)

task_list.sort(key=lambda task_list: task_list[1])
time = 0
flag = True

for i in range(N):
    x = task_list[i]
    time += x[0]
    if time > x[1]:
        flag = False
        break

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




#りゅうせいの解答1　実行時エラー、実行時間超過
# N = int(input())
# task_list = [list(map(int,input().split())) for i in range(N)]
#
# task_list.sort(key= lambda task_list: task_list[1])
# time = 0
#
# while(len(task_list)):
#     x = task_list.pop(0)
#     time += x[0]
#     if time > x[1]:
#         print("No")
#         exit(1)
#
#     else:
#         continue
#
# print("Yes")

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
W = [list(map(int,input().split())) for i in range(N)]
W.sort(key=itemgetter(1))
time = W[0][0]
if time > W[0][1]:
    print('No')
else:
    for i in range(1, N):
        w = W[i]
        time = time + w[0]
        if time > w[1]:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
W = [list(map(int,input().split())) for i in range(N)]
W.sort(key=itemgetter(1))
dp = [0] * N
dp[0] = W[0][0]
if dp[0] > W[0][1]:
    print('NO')
else:
    for i in range(1, N):
        w = W[i]
        dp[i] = dp[i-1] + w[0]
        if dp[i] > w[1]:
            print('No')
            exit()
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
print(A)
for i in range(N):
    t += A[i][0]
    if t > A[i][1]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [list(map(int, input().split())) for k in range(n)]
a.sort(key = lambda x: x[1])
worktime = 0
deadline = 0
for i in range(n):
    if worktime <= deadline:
        worktime += a[i][0]
        deadline = a[i][1]
    else:
        print('No')
        break
if worktime <= deadline:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
class Task:
    count=0
    def __init__(self,time,deadline):
        Task.count+=1
        self.time=time
        self.deadline=deadline
        self.count=Task.count
    
    def __lt__(self,other):
        if self.deadline-self.time<other.deadline-other.time:
            return True
        if self.deadline-self.time==other.deadline-other.time:
            if self.deadline<other.deadline:
                return True
            if self.deadline==other.deadline:
                if self.count<other.count:
                    return True
        return False
    
    def __gt__(self,other):
        if self.deadline-self.time>other.deadline-other.time:
            return True
        if self.deadline-self.time==other.deadline-other.time:
            if self.deadline>other.deadline:
                return True
            if self.deadline==other.deadline:
                if self.count>other.count:
                    return True
        return False

import heapq
tasklist=[]    
n=int(input())
for i in range(n):
    time,deadline=[int(j) for j in input().split()]
    task=Task(time,deadline)
    heapq.heappush(tasklist,task)
check=0
time=0


while tasklist:
    task=heapq.heappop(tasklist)
    if task.time+time>task.deadline:
        check+=1
        print("No")
        break
    else:
        time+=task.time
if check==0:
    print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    ab = []
    for _ in range(n):
        a, b = list(map(int, input().split()))
        ab.append((a, b))
    sum_a = sum([a for a, _ in ab])
    print('No' if sum_a > max([b for _, b in ab]) else 'Yes')


main()

Submission status: Wrong Answer

Solution code:
n=int(input())
su=0
mx=-1
flag=True
for i in range(n):
    [p,q]=[int(x) for x in input().split()]
    if p>q:
        flag=False
        print("No")
        break
    su+=p
    mx=max(mx,q)
if flag:
    if(su>mx):
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
su=0
mx=-1
for i in range(n):
    [p,q]=[int(x) for x in input().split()]
    su+=p
    mx=max(mx,q)
if(su>mx):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

A = sorted(A, key=lambda x: x[1])
sum=0
for i in range(n):
  sum+=A[i][0]
  if sum>A[i][1]:
    print('No')
    print(A)
    print(i)
    break
  if i==n-1:
    print('Yes')

Submission status: Wrong Answer

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

A = sorted(A, key=lambda x: x[1])
sum=0
for i in range(n):
  sum+=A[i][0]
  if sum>=A[i][1]:
    print('No')
    break
  if i==n-1:
    print('Yes')

Submission status: Wrong Answer

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

A = sorted(A, key=lambda x: x[1])
sum=0
for i in range(n):
  sum+=A[i][0]
  if sum>=A[i][1]:
    print('No')
    print(A)
    print(i)
    break
  if i==n-1:
    print('Yes')

Submission status: Wrong Answer

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

std = sorted(A, key=lambda x: x[1])
sum=0
for i in range(n):
  sum+=A[i][0]
  if sum>=A[i][1]:
    print('No')
    break
  if i==n-1:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

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

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

t=0
for i in w:
  t=t+i[0]
  if t>i[1]:
    print("NO")
    sys.exit()

print("YES")

Submission status: Wrong Answer

Solution code:
n = int(input())
count = 0
deadline = 0
for i in range(n):
    t, dl = map(int, input().split())
    count += t
    deadline = max(deadline, dl)
    if count > deadline:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
#ABC131 D
from operator import itemgetter as ig
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = (int(_) for _ in input().split())
AB = sorted([(A[i], B[i])for i in range(N)], key = ig(1))
print(AB)
last = 0
ans = True
for i in range(N):
    last += AB[i][0]
    print(AB[i][1], last)
    if last <= AB[i][1]:
        continue
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#ABC131 D
from operator import itemgetter as ig
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = (int(_) for _ in input().split())
AB = sorted([(A[i], B[i])for i in range(N)], key = ig(1))
last = 0
ans = True
for i in range(N):
    last += AB[i][0]
    if last < AB[i][1]:
        continue
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
ba = []
for i in range(n):
    a, b = (int(j) for j in input().split())
    tmp = []
    tmp.append(b)
    tmp.append(a)
    ba.append(tmp)
ba.sort()
print(ba)
s = 0
f = True
for i in range(n):
    s += ba[i][1]
    if ba[i][0] < s:
        f = False
        break
if f:
    print("Yes")
else:
    print("No")

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]=[A[i],B[i]]
C.sort(key=lambda x:(x[1],x[0]))
print(C)
t=0
for i in range(N):
    t+=C[i][0]
    if C[i][1]<t:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
a = 0
flag = 0

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

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

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

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

Submission status: Wrong Answer

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

def canFinishJobs(arr):
  arr.sort(key=lambda x: x[1])
  sum = 0
  for i in arr:
    sum += i[0]
    if sum > i[1]:
      return "NO"
  return "YES"

result = canFinishJobs(pairs)
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())

jobs = []
for _ in range(n):
    jobs.append([int(i) for i in raw_input().split()])

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

finish_time = 0

result = True
for job in jobs:
    finish_time = finish_time + job[0]
    if finish_time > job[1]:
        result = False
        break

if result:
    print "YES"
else:
    print "NO"

Submission status: Wrong Answer

Solution code:
a = [int(input()) for i in range(1)]
n = a[0] 
works = [list(map(int, input().split())) for i in range(n)]
#print(works)
works = sorted(works, key=lambda x: x[1])

time = 0
flag = 0
#print(works[1][0])

for k in range(n):
  time += works[k][0]
  if time > works[k][1]:
    flag = 1
  print(time)
    
if flag == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = [int(input()) for i in range(1)]
n = a[0]
works = [list(map(int, input().split())) for i in range(n)]
#print(works)  
works = sorted(works, key=lambda x: x[1])
print(works)
work_time = 0
for w in works:
  work_time += w[0]
  if work_time > w[1]:
    print("No")
    break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
a = [int(input()) for i in range(1)]
n = a[0] 
works = [list(map(int, input().split())) for i in range(n)]
#print(works)
works = sorted(works, key=lambda x: x[1])

time = 0
flag = 0
#print(works[1][0])

for k in range(n):
  time += works[k][0]
  if time > works[k][1]:
    flag = 1
    
if flag == 0:
  print('YES')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = [int(input()) for i in range(1)]
n = a[0]
works = [list(map(int, input().split())) for i in range(n)]
#print(works)  
works = sorted(works, key=lambda x: x[1])
print(works)
work_time = 0
for w in works:
  work_time += w[0]
  if work_time > w[1]:
    print("No")
    print(w)
    break
else:
  print("Yes")

Submission status: Wrong Answer

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

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

work = 0
flag = 0
for i in range(n):
    work += b[i][0]
    if work > b[i][1]:
        flag = 1
        print("No")

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

Submission status: Wrong Answer

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

print(A)
B = sorted(A, key=lambda x: x[1])
#print(sorted(A, key=lambda x: x[1]))

count = 0
limit = 0
for i in range(N):
    count += B[i][0]
    if count <= B[i][1]:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

a_list = []
b_list = []

for i in range(n):
  a, b = map(int, input().split())
  a_list.append(int(a))
  b_list.append(int(b))
  
b_sorted = sorted(b_list)

time = 0
deadline = 0
for i in range(n):
  for j in range(n):
    if b_list[j]==b_sorted[i]:
      time += a_list[j]
      deadline += b_list[j]
      break
  if time > deadline:
    print('No')
    break
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
works = [tuple(map(int, input().split())) for _ in range(n)]
works.sort(key=lambda x: x[1])
print(works)
time = 0
for work in works:
    time += work[0]
    if time > work[1]:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j][1] < a[j-1][1]:
                a[j][1], a[j-1][1] = a[j-1][1], a[j][1]
    return a


N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
ab = bSort(ab)
for i in range(N):
    for j in range(i, N):
        ab[j][1] -= ab[i][0]
        if ab[j][1] < 0:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

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



def f(a_p, b_p, offset, a_n, b_n):
    min_b = min(b_p, b_n)
    max_b = max(b_p, b_n)
    total_a = a_p + a_n
    if total_a <= min_b:
        return total_a, min_b, offset
    else:
        return total_a, max_b, offset + total_a

pa, pb, poffset = (0, 10**9, 0)
for a, b in sorted(a_b_list, key=lambda x: x[1]):
    pa, pb, poffset = f(pa, pb, poffset, a, b)
    if pb < pa:
        print('No')
        sys.exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
sche = []
for i in range(n):
    a,b = map(int,input().split())
    sche.append((b,a))
sche.sort(reverse = True)
now = 1e18
for dead,ti in sche:
    if(dead > now):
        dead = now
    now -= ti

if now < 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# Now = 0
# Work Number = N
# Work Id = i
# Work Time = Ai
# Work DeadLine = Bi

N = int(input())
works = [[int(i) for i in input().split()] for _ in range(N)]
elapsed = 0

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

for work in works:
    time, deadline = work
    print(elapsed, time, deadline)
    if elapsed + time <= deadline:
        elapsed += time
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:

n = int(input())
a = []
i = 0
while i < n:
    a.append(list(map(int, input().split())))
    i += 1

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

i = 0
t = 0
while i < n:
    t += a[i][0]
    if t > a[i][1]:
        break
    i += 1

print("YES" if i >= n else "NO")

Submission status: Wrong Answer

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from operator import itemgetter

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

l.sort(key=itemgetter(1))
t = 0
for i in l:
    t += i[0]
    if t > i[1]:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

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

for i in range(n):
    task.append([int(j) for j in input().split()])

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

Submission status: Wrong Answer

Solution code:
n = int(input())
task = []
for i in range(n):
    task.append([int(j) for j in input().split()])

Submission status: Wrong Answer

Solution code:
N = input()
for i in range(int(N)):
  input()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]
jobs = sorted(jobs, key=lambda x: x[1])

elapsed_time = 0
for job in jobs:
  if elapsed_time + job[0] <= job[1]:
    elapsed_time += job[0]
  else:
    print('No')
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = [list(map(int,input().split())) for i in range(N)]
ab.sort(key=lambda x:x[1])
p = ab.pop()
suma = 0
for i in range(N-1):
    suma += ab[i][0]
    print(suma,ab[i][1])
    if suma > ab[i][1]:
        print("No")
        exit()
    
print("Yes" if suma+p[0]<=p[1] else "No")

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
List = []
for i in range(N):
    tmp_a,tmp_b = map(int,input().split())
    List.append([tmp_b,tmp_a])
List.sort()
Sum_a= 0

for i in range(N):
    Sum_a += List[i][1]
    if Sum_a > List[i][0]:
        print('No')
        sys.exit()
print('YES')

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda AB:AB[1])
sum = 0
flag = 0
for i in range(len(AB)):
    print(i)
    sum += AB[i][0]
    if sum > AB[i][1]:
        flag = 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
start = []
end = []
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda AB:AB[1])
sum = 0
flag = 0
for i in range(len(AB)-1):
    sum += AB[i][0]
    if sum > AB[i][1]:
        flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
ab = [[int(x) for x in  input().split(" ")] for _ in range(n)]

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

t = 0

for a, b in ab:
    t += a
    if t > b:
        print("No")
        break
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
ab = [[int(x) for x in  input().split(" ")] for _ in range(n)]

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

t = 0

for a, b in ab:
    t += a
    if a > b:
        print("No")
        break
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

ab = []

for _ in range(n):

	ab.append(list(map(int, input().split())))
	

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

# print(ab)


limit = 0

work = 0

fail = 0


for i in range(n):

	limit = ab[i][1]

	work += ab[i][0]

	print(limit, work)

	if work > limit:

		fail = 1

		break


if fail == 1:

	print("No")

else:

	print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    T = [ tuple( map( int, input().split())) for _ in range(N)]
    sorted(T,key=lambda x:x[1])
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][0]
        if time > T[i][1]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    T = [ tuple( map( int, input().split())) for _ in range(N)]
    sorted(T,key=lambda x:x[1])
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][0]
        if time > T[i][1]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
work=[None]*N
for i in range(N):
    work[i]= list(map(int, input().split()))
work=sorted(work,key=lambda work:work[1])
time=0
flag=0
for i,j in work:
    time += i
    if time > j:
        print("No")
        flag=1
if flag==0:
    print("Yes")