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: Runtime Error

Solution code:
import sys
n = int(input())
now_time = 0

def finish_work(now_time, works):
    if len(works) == 0:
        print("Yes")
        sys.exit()
        return 0
    sums = sum([i[0] for i in works]) 
    maxs = max ([i[1] for i in works])
    if maxs < sums:
        return 0
    for index, i in enumerate(works):
        if now_time + i[0] <= i[1]:
            work_list = works.copy()
            work_list.pop(index)
            finish_work(now_time + i[0], work_list)

works = [list(map(int, input().split()) )for _ in range(n)]
sorted(works, key = lambda x : x[0] - x[1])
for index, i in enumerate(works):
    
    if now_time + i[0] <= i[1]:
        work_list = works.copy()
        work_list.pop(index)
        finish_work(now_time + i[0], work_list)


print("No")

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
now_time = 0

def finish_work(now_time, works):
    if len(works) == 0:
        print("Yes")
        sys.exit()
        return 0
    sums = sum([i[0] for i in works]) 
    maxs = max ([i[1] for i in works])
    if maxs < sums:
        return 0
    for index, i in enumerate(works):
        if now_time + i[0] <= i[1]:
            work_list = works.copy()
            work_list.pop(index)
            finish_work(now_time + i[0], work_list)

works = []

for i in range(n):
    a = list(map(int, input().split()))
    works.append(a)

for index, i in enumerate(works):
    
    if now_time + i[0] <= i[1]:
        work_list = works.copy()
        work_list.pop(index)
        finish_work(now_time + i[0], work_list)


print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
now_time = 0
global tf
tf = False

def finish_work(now_time, works):
    global tf
    if len(works) == 0 or tf == True:
        tf = True
        return True
    sums = sum([i[0] for i in works]) 
    maxs = max ([i[1] for i in works])
    if maxs < sums:
        return 0
    for index, i in enumerate(works):
        if now_time + i[0] <= i[1]:
            work_list = works.copy()
            work_list.pop(index)
            finish_work(now_time + i[0], work_list)

works = []

for i in range(n):
    a = list(map(int, input().split()))
    works.append(a)

for index, i in enumerate(works):
    
    if now_time + i[0] <= i[1]:
        work_list = works.copy()
        work_list.pop(index)
        finish_work(now_time + i[0], work_list)

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

Submission status: Runtime Error

Solution code:
n = int(input())
now_time = 0
global tf
tf = False

def finish_work(now_time, works):
    global tf
    if len(works) == 0:
        tf = True
        return True

    sums = sum([i[0] for i in works]) 
    maxs = max ([i[1] for i in works])
    if maxs < sums:
        return 0

    for index, i in enumerate(works):
        work_list = works.copy()
        work_list.pop(index)
        if now_time + i[0] <= i[1]:
            finish_work(now_time + i[0], work_list)

works = []

for i in range(n):
    a = list(map(int, input().split()))
    works.append(a)

for index, i in enumerate(works):
    work_list = works.copy()
    work_list.pop(index)
    if now_time + i[0] <= i[1]:
        finish_work(now_time + i[0], work_list)

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

Submission status: Runtime Error

Solution code:
n = int(input())
now_time = 0
global tf
tf = False

def finish_work(now_time, works):
    global tf
    if len(works) == 0:
        tf = True
        return True
    for index, i in enumerate(works):
        work_list = works.copy()
        work_list.pop(index)
        if now_time + i[0] <= i[1]:
            finish_work(now_time + i[0], work_list)

works = []

for i in range(n):
    a = list(map(int, input().split()))
    works.append(a)


for index, i in enumerate(works):
    work_list = works.copy()
    work_list.pop(index)
    if now_time + i[0] <= i[1]:
        finish_work(now_time + i[0], work_list)

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

Submission status: Runtime Error

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)

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

Submission status: Runtime Error

Solution code:
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  M[0],M[1]=M[1],M[0]
  task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
  K += task[i,1]
  if (K>task[i,0]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  swap(M[0],M[1])
  task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
  K += task[i,1]
  if (K>task[i,0]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  task.append(M)
task.sort(1)
K = 0
ans = 1
for i in range(N):
  K += task[i,0]
  if (K>task[i,1]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import itemgetter
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  task.append(M)
task.sort(key = itemgetter(1))
K = 0
ans = 1
for i in range(N):
  K += task[i,0]
  if (K>task[i,1]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import itemgetter()
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  task.append(M)
task.sort(key = itemgetter(1))
K = 0
ans = 1
for i in range(N):
  K += task[i,0]
  if (K>task[i,1]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import math
a,b,c,d=map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
e = round(c * d / gcd(c, d))

f=(a-1)//c
g=b//c
h=(a-1)//d 
k=b//d
l=(a-1)//e
m=b//e

x=(b-a+1)
y=g-f
z=k-h
w=m-l
print(f,g,h,k,l,m)
print(x-y-z+w)

Submission status: Runtime Error

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] = [int(j) for j in input().split()]

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

for i in range(N-1):
	A[i+1, 0] = A[i, 0]+A[i+1, 0]

ans = ['Yes', 'No']
print(ans[np.sum((A[:,1]-A[:,0])<0)])

Submission status: Runtime Error

Solution code:
n=int(input())
d=[]
judge=True
bag=[]
for i in range(n):
    a,b=map(int,input().split())
    d.append([a,b])
d.sort(key=itemgetter(1))
        
for j in range(len(d)):
    bag.append(d[j][0])
    if sum(bag)>d[j][1]:
        judge=False
else:
    if judge==True:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
def qSort(a):
    if len(a) in (0, 1):
        return a

    p = a[-1]
    l = [x for x in a[:-1] if x[1] <= p[1]]
    r = [x for x in a[:-1] if x[1] > p[1]]

    return qSort(l) + [p] + qSort(r)


N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
ab = qSort(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: Runtime Error

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 :
    if(dead > now):
        dead = now
    now -= ti

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

Submission status: Runtime Error

Solution code:
c = 10**9+7

n, k = map(int, input().split())

def combinations_count_mod(n, r):
  ret = 1
  for i in range(r):
    ret *= (n-i)/(r-i) % c
  return ret

for i in range(1, k+1):
  a = combinations_count_mod(k-1, i-1) 
  if n-k > i-1:
#    if n-k-i >= 1:
    b = (combinations_count_mod(n-k-1, i-1) * ((n-k-1-(i-1))/i + 2)) 
#    else:
#      b = (n-k-1) * 3
  elif n-k == i-1:
    b = 1
  else:
    b = 0
  print(int((a*b) % c))

Submission status: Runtime Error

Solution code:
n=int(input())
time=0
job=[]
for i in range(n):
    j,t=map(int,input().split())
    time = max(time,t)
    job.append([j,t])

job_tbl=[0]*(time+1)

for i in range(n):
    job_tbl[job[i][1]] += job[i][0]

ruiseki = 0

for i in range(time+1):
    ruiseki += job_tbl[i]
    if ruiseki > i:
        print('No')
        exit()

print('Yes')

Submission status: Runtime Error

Solution code:
import math
N, K = (int(i) for i in input().split())
R = N-K

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for i in range(1, K+1):
    print(((cmb(K-1, i-1))*cmb(i+1+R-(i-1)-1, R-(i-1)))%(10**9+7))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda X:X[1])
time = 0
ans = 'Yes'
for i in range(N):
  time += X[0][i]
  line = X[i][1]
  if line < time :
    ans = 'No'
print(ans)

Submission status: Runtime Error

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

time = 0

for i, a, b in AB:
    time += a
    if time > b:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
N=int(input())
import numpy as np
A=np.zeros(N)
B=np.zeros(N)
for i in range(0,N):
  A[i],B[i] = map(int,input().split())
  
W=np.zeros((N,np.max(B)))
for i in range(0,N):
  for j in range(int(B[i]-A[i]),int(B[i])):
    W[i][j]=1
    
for b in B:
  if np.sum(W[:,0:b]) > b:
    print('No')
    break
else:
  print('Yes')

Submission status: Runtime Error

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
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time + = s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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: Runtime Error

Solution code:
N = int(input())
p = [[0,0]]*N
for i in range(N):
  p[i] = input().split()
  p[i] = list(map(int,p[i]))
p = sorted(p,key = lambda x:x=p[1])
s = [0]*N
s[0] = p[0][0]
for i in range(N-1):
  s[i+1] = s[i] + p[i+1][0]
k = 0
for i in range(N):
  if s[i] <= p[i][1]:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define LL long long int


using namespace std;

LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}



int main(void){
    int c;
    cin >>c;
    vector<pair<int,int>> tasks(c);
    
    rep(i,c){
        int a,b;
        cin >>a>>b;
        tasks[i].first=b;
        tasks[i].second=a;
    }
    sort(tasks.begin(),tasks.end());
    LL sum =0;
    string ans ="Yes";


    rep(i,c){
        sum+=tasks[i].second;
        if (sum>tasks[i].first){
            ans="No";
            break;
        }
    }
    cout << ans<<endl;
    return 0;

}

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
s= n
ans=[]
freeNode = [2]
cur=2
ans.append([1,2])
if n==2 :
    if k>0:
        print(-1)
    else:
        print(1)
        print(1, 2)
        exit()
else:
    s=0
    c=1
    if (n-2)*(n-1)//2<k:
        print(-1)
        exit()
    else:
        while(1):
            s += c
            cur+=1
            c+=1
            freeNode.append(cur)
            ans.append([1,cur])
            if s >=k:
                break
    if cur!=n:
        remove = s-k;
        if remove:
            for v in freeNode:
                ans.append([v,cur])
                remove-=1
                if remove==0:
                    break
        for i in range(cur + 1, n + 1):
            cur+=1
            for j in range(1, cur):
                ans.append([i, j])
        print(len(ans))
        for u,v in ans:
            print(u,v)
    else:
        remove = s - k;
        if remove:
            for v in freeNode:
                ans.append([v, cur])
                remove -= 1
                if remove == 0:
                    break
        print(len(ans))
        for u, v in ans:
            print(u, v)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input() )

for i in range(N):
  A, B = map(int, input().split() )
  C[i] = [A, B]
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Submission status: Runtime Error

Solution code:
N = int(input() )
for i in range(N):
  C[i] = (map(int, input().split() ) )
 
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Submission status: Runtime Error

Solution code:
N = int(input() )
for i in range(N):
  C[i] = [map(int, input().split() ) ]
 
C.sort(key= lambda s:(s[1],s[0]) )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Submission status: Runtime Error

Solution code:
N = int(input() )
for i in range(N):
  C[i] = list(map(int, input().split() ) )
 
C.sort(key= lambda s:(s[1],s[0]) )
 
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
end_time = [list(map(int, input().split())) for i in range(N)]
dic_item = {}
for i in range(N):
    dic_item[i+1] = end_time

tmp_work = [] #仮順番
per_work = [] #完全に固定の順番

tmp_time = sorted(end_time, key=lambda x: x[1])
for item in tmp_time:
    for k, v in dic_item.items():
        if item[0] == v[0] and item[1] == v[1]:
            tmp_work.append(k)
n = 0 #累積終了和
for num in tmp_work:
    n += dic_item[num][0]
    if n > dic_item[num][1]:
        ans = "No"
        break
    else:
        ans = "Yes"
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = 3

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

for NN in range(N):
    hyo[NN] = input().split(' ')

hyo_sorted = hyo[np.argsort(hyo[:,1])]

tooktime = hyo_sorted[:,0].cumsum()

timeup = hyo_sorted[:,1]

if any(tooktime > timeup) ==True:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

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
for i in l:
    a,b=i
    t+=a
    if(t>b):
        print("No")
        break
    else:
        print("Yes");

Submission status: Runtime Error

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())
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()

part_A = [0 for i in range(N)]
tmp  = 0
for i in range(N):
    b,a = BA[i]
    tmp += a
    if B - tmp < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

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())
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()
part_A = [0 for i in range(N)]
for i in range(N):
    B,A = BA[i]
    part_A[i] = A + part_A[i-1]

for i in range(N):
    B,A = BA[i]
    if B - part_A < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
l = [[int(j) for j in input().split()] for i in range(N)]
l = sorted(l, 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: Runtime Error

Solution code:
import fractions
a, b, c, d = map(int, input().split())
 
def wareruzu(x):
    if b < x:
        return 0
    if b == x:
        return 1
    start_a = a if a % x == 0 else a - (a % x) + x
    end_b = b - (b % x)
    m = end_b - start_a
    return int(m / x) + 1
 
all_n = b - a + 1
print(all_n - wareruzu(c) - wareruzu(d) + wareruzu((c*d) / fractions.gcd(c,d)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
H = int(input())
A = [list(map(int, input().split())) for _ in range(H)]

B = np.array(A).T
C = np.array([B[1], B[0]])
D = np.sort(B[1])
E = np.argsort(B[1])
F = B[0]
G = B[1]
I= E.tolist()
print(I)
sum = 0
answer = 0
for n in range(len(E)):
    variab = I.index(n) + 1
    print(variab)
    sum += F[variab]
    print(sum)
    if sum <= G[variab]:
      	answer += 1
print(answer)
if answer == H:
  	print("Yes")
else:
  	print("No")

Submission status: Runtime Error

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]==AB[1]==(334,1000):clear = True
if clear:print("Yes")
else:print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

now_time = 0
flag = True
for a,b in tasks:
  if now_time + a > b:
    flag = False
    break
  now_time += a
if flag:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
ソースコード 

Copy
Copy
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])

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: Runtime Error

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 > task[i][i]:
    output = 'No'
    break

print(output)

Submission status: Runtime Error

Solution code:
N = int(input())
A_list = []
B_list = []
count = 0
D = 0
for i in range(N):
  A,B = map(int, input().split())
  A_list.append(A)
  B_list.append(B)
c = zip(A, B)
c.sort(key = itemgetter(1))
A, B = zip(*c)
for o in range(N):
  count += A[i]
  if count > B[i]:
    print("No")
    D = 1
    break
if D== 0:
  print("Yes")

Submission status: Runtime Error

Solution code:
from operator import itemgetter

N = int(input())
AB = [[int(x) for x in input().split()]for _ in range(N)]
sum_time = sum([a for a,b in AB])
AB.sort(key=itemgetter(0))
AB.sort(key=itemgetter(1),reverse=True)
for a,b,t in AB:
    if(sum_time>b):
        print('No')
        break
    else:
        sum_time-=a
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
def addTimesheet(ts, a, b):
    for i in range(0, len(ts)):
        if(not ts[i] is 1):
            ts[i] = 1
            a -= 1
        if(a is 0):
            break
    if(not a is 0):
      return ts, False
    return ts, True

n = int(input())
a = []
b = []
for i in range(0, n):
    str = input().split(" ")
    a.append(int(str[0]))
    b.append(int(str[1]))

timesheet = [0]*max(b)
flag = True
for ia, ib in zip(a, b):
    timesheet, flag = addTimesheet(timesheet, ia, ib)
    if(flag is False):
    	break
if(flag is True):
	print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def addTimesheet(ts, a, b):
    for i in range(0, len(ts)):
        if(not ts[i] is 1):
            ts[i] = 1
            a -= 1
        if(a is 0):
            break
    if(not a is 0):
      return ts, False
    return ts, True

n = int(input())
a = []
b = []
for i in range(0, n):
    str = input().split(" ")
    a.append(int(str[0]))
    b.append(int(str[1]))

timesheet = [0]*max(b)

for ia, ib in zip(a, b):
    timesheet, flag = addTimesheet(timesheet, ia, ib)
    if(flag is False):
    	break
if(flag is True):
	print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

a_list.sort(key = sortSecond)

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

print(detect(a_list))

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
ab = [int(input())for _ in range(n)]

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

ab = np.array(ab)
memo = ab.sum(axis=0)[0]
f = False  # flag

for x in ab:
    if memo <= x[1]:
        memo -= x[0]
    else:
        f = True
        break
if f:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

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:
  	while True:
      B = B + 0.000001
      if not B in AB:
        AB[B] = A
      

AB.sort()
kk = 0
TF = True
for i in AB:
  kk += AB[i]
  imi = round(i)
  if kk > imi:
    TF = False
    break

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

Submission status: Runtime Error

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):
	time += listC[i][0]
	#print(time)
	listC.pop(0)
	if time > listC[i][1]:
		flag = 1
		break
 
if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Submission status: Runtime Error

Solution code:
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])
 
now = 0
for i in range(N):
    if tt <= dat[i][1]:
        ass += 1
        tt = tt + dat[i][0]

#print(ass)
if tt <= dat[N-1][0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from operator import itemgetter

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()
sums = 0
correct = 1
for i in range(N):
    sums+=c[i][0]
    if b[i][1] >sums:
        correct=0
        break

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

Submission status: Runtime Error

Solution code:
n = int(input())

 task_lis = sorted([[int(i) for i in input().split()] for _ in range(n)], key = lambda x:x[1])


sum_a = 0
ch_over = 1

for i in range(n):
    sum_a += task_lis[i][1]
    if task_lis[i][0] < sum_a:
        ch_over = 0
        break

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

Submission status: Runtime Error

Solution code:
n = int(input())

 task_lis = sorted([[int(i) for i in input().split()] for _ in range(n)])


sum_a = 0
ch_over = 1

for i in range(n):
    sum_a += task_lis[i][1]
    if task_lis[i][0] < sum_a:
        ch_over = 0
        break

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

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())  

A = np.zeros(N) 
B = np.zeros(N) 

for i in range(N):
    A[i], B[i] = map(int, input().split())
    
B1 = B[np.argsort(B)]

ans = "Yes"
 
k = 0
for i in range(N):
    k += A[B1[i]]
    if k > B[B1[i]]:
        ans = "No"
 
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())

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


def yes_or_no():
    for c in C:
        if c < 0:
            return 0
    
    sorted_index = np.argsort(B)
    sum_A = [A[sorted_index[0]]]
    for i in range(1, N):
        next_num = sum_A[i-1] + A[sorted_index[i]]
        sum_A.append(next_num)
        if next_num > B[sorted_index[i]]:
            print(sum_A)
            return 0
        
    return 1

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

Submission status: Runtime Error

Solution code:
n = int(input())

 task_lis = [[int(r) for i in input().split()] for _ in range(n)]


sum_a = 0
ch_over = 1

for i in range(n):
    sum_a += task_lis[i][1]
    if task_lis[i][0] < sum_a:
        ch_over = 0
        break

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0] * N
B = [0] * N
AB = [0] * N
BA = [0] * N
need = {}
for i in range(N):
    A[i], B[i] = [int(x) for x in input().split()]
    need[B[i]] = A[i]
    BA[i] = [B[i], A[i]]
list.sort(BA)
t = 0
fail = 0
for n in range(N):å
    t += BA[n][1]
    if t > BA[n][0]:
        fail = 1
        break
if fail:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))
    
l = sp.array(sorted(l, key=lambda x: x[1]))

a = sp.cumsum(l[:,0])
b = l[:,1]

c = b-a
t = True
for i in c:
    if i < 0:
        t = False
        print("No")

if t:
    print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
b=[]
gap=0
m=0
for i in range(n):
    c,d=map(int,input().split())
    a.append(c)
    b.append(d)
while (gap<=n/9):
    gap=gap*3+1
def shellsort(b):
    while (gap<=n/9):
    gap=gap*3+1
    while (gap>0):
        for i in range(gap,n):
            key=b[i]
            l=a[i]
            if(key<b[i-gap]):
                j=i
                while True:
                    b[j]=b[j-gap]
                    a[j]=a[j-gap]
                    j-=gap
                    if(j<gap or key>=b[j-gap]):
                        break
                b[j]=key
                a[j]=l
for i in range(n):
    e+=a[i]
    f+=b[i]
    if(e>f):
        m=1
if(m=1):
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    work = []
    for i in range(n):
        a, b = map(int, input().split())
        #(順番、単位時間、締め切り)
        work.append((i,a,b))

    work.sort(key= lambda x:x[2])
    ans = 0
    for i in range(n):
        ans += work[n][1]
        if ans < work[n][2]:
            print("Yes")
        else:
            print("No")

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
t = []
for i in range (n):
    task = tuple(map(int,input().split()))
    t.append(task)
tasks = dict(t)
st = sorted(tasks.items(), key=lambda x:x[1])
time = 0
ans = "Yes"
for j in range(n) :
    time += st[j][0]
    if time > st[j][1]:
        ans = "No"
print(ans)