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:
N = int(input())
lis = []
for i in range(N):
    lis.append(map(int,input().split()))
lis.sort(key = lambda x:x[1])
a = 0
for j in range(N):
    a += lis[j][0]
    if a > lis[j][1]:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  a, b, c, d = map(int, input().split())
  a -= 1
  lc = (c*d)//fractions.gcd(c,d)
  ans = (b-a)-(b//c-a//c)-(b//d-a//d)+(b//lc-a//lc)
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

 task.sort(key= lambda x:x[1])
 time = 0
 for a,b in task:
     time += a
     if time > b:
         print("No")
         break
    else:
        print("Yes")

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sort()
li = li[::-1]

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sorted(reverse=True)

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

n = int(input())

a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = np.array(a)
b = np.array(b)

diff = b - a

li = []
for x, y, z in zip(diff, a, b):
    li.append((x, y, z))

li = sortted(reverse=True)

stack = 0
for _, a, b in li:
    stack += a
    if stack > b:
        print("No")
        sys.exit()

print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())

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

time=0
for item in ba:
  b=item[0]
  a=item[1]
  
  time+=b
  if time>a:
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
def merge_sort(arr):
 if len(arr) <= 1:
  return arr
 mid = len(arr) // 2
# ここで分割を行う
 left = arr[:mid]
 right = arr[mid:]
# 再帰的に分割を行う
 left = merge_sort(left)
 right = merge_sort(right)
# returnが返ってきたら、結合を行い、結合したものを次に渡す
 return merge(left, right)
def merge(left, right):
 merged = []
 l_i, r_i = 0, 0
# ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
 while l_i < len(left) and r_i < len(right):
    # ここで=をつけることで安定性を保っている
  if left[l_i][1] <= right[r_i][1]:
   merged.append(left[l_i])
   l_i += 1
  else:
   merged.append(right[r_i])
   r_i += 1

# 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
 if l_i < len(left):
  merged.extend(left[l_i:])
 if r_i < len(right):
  merged.extend(right[r_i:])
 return merged
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
for i in range(N):
 lst=[list[map(int,input().split())] for i in range(n)]
lsta=merge_sort(lst)
ans=0
t=0
for i in range(N):
 t+=lsta[i][0]
 if t>lsta[i][1]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")

Submission status: Runtime Error

Solution code:
 int(input())
 
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
 
C = zip(B, A)
C = sorted(C)
B, A = zip(*C)
 
ans = 1
t = 0
for i, j in zip(A, B):
    t += i
    if t <= j:
        continue
    else:
        print("No")
        ans = 0
        break
if ans:
    print("Yes")

Submission status: Runtime Error

Solution code:
def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [0] * N
B = [0] * N

for _ in range(N):
    A[_], B[_] = map(int, input().split())
    if sum(A) > max(B):
        print("No")
        sys.exit()

if cnt == N:
    print("Yes")

Submission status: Runtime Error

Solution code:
# 締切の早いものから順番に見ていくのが最適戦略
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda x: x[1])  # B (締切の早い順にソート)

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

Submission status: Runtime Error

Solution code:
# 締切の早いものから順番に見ていくのが最適戦略
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda x: x[1])  # B (締切の早い順にソート)
diff = 0
for i in range(N):
    diff += B[i] - A[i]
    if diff < 0:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
from sys import exit
input = sys.stdin.readline

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
from sys import
input = sys.stdin.readline

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

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

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

q = 0
w = 0
flg = 0
for j in range(n):
  q += j[0]
  w += j[1]
  if q > w :
    flg = 1
    break

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

Submission status: Runtime Error

Solution code:
N = int(input())
H = []
for _ in range(N):
    A, B = map(int,input().split())
    H.append((B, A))
H.sort()
t = 0
for i in range(N):
    B, A = H[i]
       t += A
    if B < t:
        print("No")
        break 
    if i == N - 1:
        print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())) for nd in range(n),key=lambda x:x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")

Submission status: Runtime Error

Solution code:
n=int(inuput())
l=sorted(list(map(int,input().split())) for nd in range(n),key=lambda x:x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")

Submission status: Runtime Error

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

job.sort(key = lambda x: x[1]

time = 0
flag = 0
for i in range(N):
    time += job[i][0]
    if time > job[i][1]:
        flag = 1 
    
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from operatpr import itemgetter

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

job.sort(key = itemgetter(1))

time = 0
flag = 0
for i in range(N):
    time += job[i][0]
    if time > job[i][1]:
        flag = 1
    print(flag)    
    
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
print("Yes")
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key= lambda x:x[1])
time = 0
for i in ab:
    time += i[0]
    if time <= i[1]:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())

A = [0]*N
B = [0]*N

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


indexes = [*range(N)]
sorted_indexes = sorted(indexes, key=lambda i: B[i])

sorted_A = [A[i] for i in sorted_indexes]
sorted_B = [B[i] for i in sorted_indexes]

total = 0
for i in range(N):
    total += sorted_A[i]
    if total <= sorted_B[i]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

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

time = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

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

for i in range(n):
  suma=sum(a)
  maxb=max(b)
  if suma<=mxb:
    index=b.index(maxb)
    del a[index]
    del b[index]
  else:
    print('No')
    exit()
print('Yes')

Submission status: Runtime Error

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

for i in range(n):
  suma=sum(a)
  maxb=max(b)
  if suma<=mxb:
    index=b.index(maxb)
    del a[index]
    del b[index]
  else:
    print('No')
    exit()
print('Yes')

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    AB = []
    n = int(input())
    for i in range(n):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key=lambda x: (x[1], -x[0]))
    time = 0
    for span, dead in zip(AB):
        time += span
        if time > dead:
            print('No')
            return
    print('Yes')
    return


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
ba_list = []
for i in range(n):
    ba_tmp = list(map(int, input().split()))
    ba_list.append([ba_tmp[1], [ba_tmp[0]])
ba_list.sort()
now_time = 0
for i in range(n):
    now_time += ba_list[i][1]
    if now_time > ba_list[i][0]:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
b_list = []
for i in range(n):
    ba_tmp = list(map(int, input().split()))
    ba_list.append([ba_tmp[1], ba_tmp[0]])
ba_list.sort()
now_time = 0
for i in range(n):
    now_time += ba_list[i][1]
    if now_time > ba_list[i][0]:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
b_list = []
for i in range(n):
    ba_tmp = list(map(int, input().split()))
    ba_list.append([ba_tmp[1], [ba_tmp[0]])
ba_list.sort()
now_time = 0
for i in range(n):
    now_time += ba_list[i][1]
    if now_time > ba_list[i][0]:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
data = [list(map(int, input().strip().split())) for _ in range(n)]

data = sorted(data, key=lambda d: d[1])

work_time = 0
impossible = False
for a, b in data:
    deadline = b
    work_time += a
    if work_time > b:
        impossible = True
        break

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

n = int(input())
data = [list(map(int, input().strip().split())) for _ in range(n)]

data = sorted(data, key=lambda d: d[1])

work_time = 0
impossible = False
for a, b in data:
    deadline = b
    work_time += a
    if work_time > b:
        impossible = True
        break

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

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = []
    B = []
    b_max = 0
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
        if b_max < b:
            b_max = b
    tasks = [0] * (b_max + 1)
    for i in range(N):
        tasks[B[i]] += A[i]
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0:
            continue
        time += task
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = []
    B = []
    b_max = 0
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
        if b_max < b:
            b_max = b
    tasks = [0] * (b_max + 1)
    for i in range(N):
        tasks[B[i]] += A[i]
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0 or task == 0:
            continue
        time += task
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        A.append(a)
        B.append(b)
    tasks = [0] * (max(B) + 1)
    for i in range(N):
        tasks[B[i]] += A[i]
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0 or task == 0:
            continue
        time += task
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
import heapq

n = int(input())
abs = [tuple(map(int, input().split())) for _ in range(n)]

pq = []

for ab in abs:
  a,b = ab[0],ab[1]
  heapq.heappush(pq, tuple(b,a))
  
dl = 0
tt = 0

ans = "Yes"

for i in range(n):
  ba = pq.pop()
  dl += ba[0]
  tt += ba[1]
  if dl > tt:
    ans = "No"
    break
print(ans)

Submission status: Runtime Error

Solution code:
#m = imt(imput())
#L = list(map(imt, imput().split()))
import math
import sys

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


def aa(N,AB):
    AB.sort(key=lambda x: x[1])
    for i in range(N-1):
        clk += AB[i][0]
        if clk >= AB[i][1]:
            flg = False
            break
    if flg:
        return "Yes"
    else:
        return "No"
print(aa(N,AB))

Submission status: Runtime Error

Solution code:
#m = imt(imput())
#L = list(map(imt, imput().split()))
import math
import sys

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


def aa(N,AB):
    AB.sort(key=lambda x: x[1])
    for i in range(N-1):
        clk += AB[i][0]
        if clk >= AB[i][1]:
            flg = False
            break
    if flg:
        return "Yes"
    else:
        return "No"
print(aa())

Submission status: Runtime Error

Solution code:
import sys
readline=sys.stdin.buffer.readline
n=int(input())
a=[list(map(int, readline().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Submission status: Runtime Error

Solution code:
import sys
readline=sys.stdin.buffer.redline
n=int(input())
a=[list(map(int, readline().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count_time = 0
for AB in ABn:
    count_time += AB[0]
    if count_time <= AB[1]:
        continue
    else:
        print('No')
        exit(1)
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
X = [0]*100000000
for i in range(n):
  a,b = map(int,input().split())
  p = b
  for j in range(a):
    while X[p]!=0:
      p-=1
      if p<0:
        print("No")
        exit()
    X[p]=1
    p-=1
    if p<0:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

class Solver7
    {
        /*
         * https://atcoder.jp/contests/abc131/tasks/abc131_d
         * 
         * 
         */
                public void Solve7()
        {
            var nnum = 99999999;
            var n = int.Parse(Console.ReadLine());
            int[] X = new int[nnum];
            
            try
            {
                for (int i = 0; i < n; i++)
                {
                    var ab = u.readIntArrayBySplit();
                    var a = ab[0];
                    var b = ab[1];
                    var p = b;
                    for (int j = 0; j < a; j++)
                    {
                      	var xx = X[p];
                      	
                        while (X[p]!=null && X[p] == 1)
                        {
                            p--;
                        }
                        X[p] = 1;
                    }
                }
                Console.WriteLine("Yes");
            }
            catch(Exception ex)
            {
                Console.WriteLine("No");
            }


        }
        static void Main()
        {
            var solver = new Solver7();
            solver.Solve7();
        }
    }
    static class u
    {
        public static void outA(int[] A) { Console.WriteLine(string.Join(" ", A)); }
        public static void outInt(int i) { Console.WriteLine(i.ToString()); }
        public static void outLong(long i) { Console.WriteLine(i.ToString()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        public static int readInt() { return int.Parse(Console.ReadLine()); }
        public static  string readStr() { return Console.ReadLine(); }
        public static int[] readIntArrayBySplit() { return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        public static int[] readIntArrayZeroIchiRenzoku() { return Console.ReadLine().Select(s => int.Parse(s.ToString())).ToArray(); }

    }

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            var AB = new int[N][];
            for(int i=0;i<N;i++){
                AB[i] = cin.ReadIntArray(2);
            }
            var ABs = AB.OrderBy(x => x[1]);
            long curtime = 0;
            string ans = "Yes";
            foreach(int[] L in ABs){
                curtime += L[0];
                if(curtime > L[1]){
                    ans = "No";
                    break;
                }
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator =' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Submission status: Runtime Error

Solution code:
N = int(input())

task = [0] * (10 ** 9 + 1)
M = 0
for _ in range(N):
    a, b = map(int, input().split())
    task[b] += a
    if b > M:
        M = b

t = 0
ans = 'Yes'
for i in range(M+1):
    t += task[i]
    if t > i:
        ans = 'No'
        break

print(ans)

Submission status: Runtime Error

Solution code:
import heapq
import copy
import bisect

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

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

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

for i in range(n):
	minimum = heapq.heappop(b2)
	index = bisect.bisect_left(b,minimum)
	for _ in range(n):
		if a2[index] == -1:
			index += 1
		else:
			break
	a2[index] = -1
	t += a[index]
	if t > minimum:
		flag = False
		break

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

Submission status: Runtime Error

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

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

Solution code:
n=int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
#print(ab)
#print(b)
k=0
for t in range(n):
    k+=ab[n-1-t][0]
    #print([k,answer])
    if k>ab[n-1-t][1]:
        answer=answer*0
if answer==1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import pandas as pd
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)

# print(list_A , list_B)

df = pd.DataFrame()
df["a"] = list_A
df["b"] = list_B
df = df.sort_values(["b", "a"]).reset_index(drop = True)
for i in df.index[1:]:
    df.loc[i, "a"] = df.loc[i, "a"] + df.loc[i-1, "a"]
    if df.loc[i, "a"] > df.loc[i, "b"]:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
    n = int(input())

Submission status: Runtime Error

Solution code:
n = int(input())
l = {}
lb = []
la = []
c = 0
for _ in range(n):
    a,b = map(int,input().split())
    l[b] = a
l = sorted(l.items())
for i in range(0,n):
    lb.append(l[i][0])
    la.append(l[i][1])

for i in range(0,n):
    if lb[i] < sum(la[:i+1]):
        c = 1
        break
    else:
        continue
if c == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>

using namespace std;

int N;
int A[200010], B[200010];
pair<int, int> C[200010];

int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i];
        //<b, i>のpairを作りAにアクセスできるようにする
        C[i] = {B[i], i};
    }
    sort(C+1, C+N+1);
    int time = 0;
    for(int i=1;i<=N;i++){
        int id = C[i].second;
        if(time + A[id] <= B[id]) time += A[id];
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
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

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

    else:
        continue

print("Yes")




#りゅうせいの解答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: Runtime Error

Solution code:
#りゅうせいの解答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")

#りゅうせいの解答2　ソートしない
N = int(input())
task_list = [list(map(int,input().split())) for i in range(N)]

time = 0

while(len(task_list)):
    idx = task_list.index(min(task_list,key = lambda task_list:task_list[1]))
    x = task_list.pop(idx)
    time += x[0]
    if time > x[1]:
        print("No")
        exit(1)

    else:
        continue

print("Yes")

Submission status: Runtime Error

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

Solution code:
#131d
N = int(input())
lst = []
for i in range(N):
    a, b = map(int, input())
    lst.append([b, a])
lst = sorted(lst)

lim = 0
time = 0
flag = 0
for i in lst:
    lim = i[0]
    if time + i[1] <= lim:
        time += i[1]
    else:
        flag = 1
        break
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

flg = True

a = np.array(jobs)[:,0]
b = np.array(jobs)[:,1]

sum = np.add.accumulate(a)
if sum(sum > b):
    print('No')
else:
    print('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, reverse = True, 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")