Problem: 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`.

Submission attempts (in order):
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')


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]]                                                                                                                                                                                      
    if time > B_[i]:                                                                                                                                                                                        
        print('No')                                                                                                                                                                                         
        sys.exit()                                                                                                                                                                                          

print('Yes')


Verdicts: Wrong Answer

Accepted