Problem:


Score : 400 points

Problem Statement

You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:

Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.

Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.

The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Constraints

1 ≤ N ≤ 10^5

1 ≤ H ≤ 10^9

1 ≤ a_i ≤ b_i ≤ 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N H
a_1 b_1
:
a_N b_N

Output

Print the minimum total number of attacks required to vanish the monster.

Sample Input 1

1 10
3 5

Sample Output 1

3

You have one katana. Wielding it deals 3 points of damage, and throwing it deals 5 points of damage. By wielding it twice and then throwing it, you will deal 3 + 3 + 5 = 11 points of damage in a total of three attacks, vanishing the monster.

Sample Input 2

2 10
3 5
2 6

Sample Output 2

2

In addition to the katana above, you also have another katana. Wielding it deals 2 points of damage, and throwing it deals 6 points of damage. By throwing both katana, you will deal 5 + 6 = 11 points of damage in two attacks, vanishing the monster.

Sample Input 3

4 1000000000
1 1
1 10000000
1 30000000
1 99999999

Sample Output 3

860000004

Sample Input 4

5 500
35 44
28 83
46 62
31 79
40 43

Sample Output 4

9



Sample input:
1 10
3 5


Sample output:
3

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, h = f()
    swords = []

    for i in range(n):
        swords.append(f())
    
    maxa = max([x[0] for x in swords])

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

    cnt = 0
    sumh = 0
    for i in range(n):
        if swords[i][1]>maxa:
            sumh += swords[i][1]
            cnt += 1
            if sumh > h:
                print(cnt)
                return
        else:
            break
    

    cnt += (h- sumh+maxa-1)//maxa

    print(cnt)






solve()

Submission status: Wrong Answer

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

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0]) 


flag = True
sorted(weapon, key=lambda x: x[1], reverse=True)
for i in range(N):
    if weapon[i][1] >= max_atack:
        count += 1
        H -= weapon[i][1]
        
        if H <= 0:
            flag = False
            break

if flag:
    if H % max_atack == 0:
        count += H // max_atack
    else:
        count += H // max_atack + 1


print(count)

Submission status: Wrong Answer

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

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0]) 


flag = True
for i in range(N):
    if weapon[i][1] >= max_atack:
        count += 1
        H -= weapon[i][1]
        
        if H <= 0:
            flag = False
            break

if flag:
    if H % max_atack == 0:
        count += H // max_atack
    else:
        count += H // max_atack + 1


print(count)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split())

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

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0])

sum_slow = 0
flag = True
for i in range(N):
    if weapon[i][1] > max_atack:
        count += 1
        H -= weapon[i][1]
        if H <= 0:
            flag = False
            break

if flag:
    if H % max_atack == 0:
        count += H // max_atack
    else:
        count += H // max_atack + 1


print(count)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split())

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

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0])

sum_slow = 0
for i in range(N):
    if weapon[i][1] > max_atack:
        count += 1
        H -= weapon[i][1]
        if H <= 0:
            break
     
if H % max_atack == 0:
    count += H // max_atack
else:
    count += H // max_atack + 1


print(count)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split())

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

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0])

flag = False
sum_slow = 0
for i in range(N):
    if weapon[i][1] > max_atack:
        count += 1
        H -= weapon[i][1]
        if H <= 0:
            break
     
if H % max_atack == 0:
    count += H // max_atack
else:
    count += H // max_atack + 1


print(count)

Submission status: Wrong Answer

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

max = max(A)
B.sort(reverse=True)

cnt,i=0,0
while H > 0:
    if i != len(B):
        if B[i] >= max:
            H -= B[i]
            i += 1
        else:
            x = round(H/max)
            H=-1
            cnt += x-1
    else:
        x = round(H/max)
        H=-1
        cnt += x-1
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
ab=[]
s=0
for i in range(n):
    ab.append([int(j) for j in input().split()])
    s+=ab[-1][1]
    
ab.sort()
fm=ab[-1][0]
nm=ab[-1][1]

from operator import itemgetter
ab.sort(key=itemgetter(1)) 
ab.reverse()

ans=0

if s>=h:
    p=0
    i=0
    while p<h:
        p+=ab[i][1]
        ans+=1
        i+=1
else:
    ab.reverse()
    s=0
    for i in range(n):
        if ab[i][1]>=fm:
            s+=ab[i][1]
            ans+=1
    import math
    ans+=math.ceil((h-s)/fm)

print(ans)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
a=list()
b=list()
maxs=0
for j in range(N):
    A,B=map(int,input().split())
    maxs+=B
    a.append(A)
    b.append(B)
maxa=max(a)
allb=sum(b)
a.sort()
b.sort()
ans=0
while len(b)>0:
    if(H<=0):
        break
    
    if(b[-1]>=maxa):
        H-=b[-1]
        b.pop()
        ans+=1
    else:
        break
ans+=H//maxa
if(H%maxa>0):
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,h = li()

def extract_gt_maxa(b: list, maxa: int) -> list:
    b.sort(reverse=True)
    ret = []
    for bi in b:
        if bi < maxa:
            break
        
        ret.append(bi)
        
    return ret

alist = []
blist = []
for _ in range(n):
    a,b = li()
    alist.append(a)
    blist.append(b)
    
b_gt_maxa = extract_gt_maxa(blist, max(alist))

ans = 0
for bi in b_gt_maxa:
    if h <= 0:
        break
    
    h -= bi
    ans += 1
    
ans += -(-h // max(alist))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
from operator import itemgetter
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,H = IL()
ab = [IL() for i in range(N)]

ab.sort(reverse=True)
attack = ab[0][0]
skill = ab[0][1]

ab.sort(reverse=True,key=itemgetter(1))
cnt = 0
f = 0
for i in range(N):
	if ab[i][0] == attack and ab[i][1] == skill and f == 0:
		f = 1
		continue
	if ab[i][1] > attack:
		H -= ab[i][1]
		cnt += 1
	if H <= 0:
		print(cnt)
		exit()

if attack < skill:
	H -= skill
	cnt += 1
if H <= 0:
	print(cnt)
else:
	print(cnt + math.ceil(H/attack))

Submission status: Wrong Answer

Solution code:
import math
from operator import itemgetter
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,H = IL()
ab = [IL() for i in range(N)]

ab.sort(reverse=True)
attack = ab[0][0]
skill = ab[0][1]

ab.sort(reverse=True,key=itemgetter(1))

cnt = 0
f = 0
for i in range(N):
	if ab[i][1] == skill and f == 0:
		f = 1
		continue
	if ab[i][1] > attack:
		H -= ab[i][1]
		cnt += 1
	if H <= 0:
		print(cnt)
		exit()

if attack < skill:
	H -= skill
	cnt += 1
if H <= 0:
	print(cnt)
else:
	print(cnt + math.ceil(H/attack))

Submission status: Wrong Answer

Solution code:
import math
from operator import itemgetter
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,H = IL()
ab = [IL() for i in range(N)]

ab.sort(reverse=True)
attack = ab[0][0]
skill = ab[0][1]

cnt = 0
f = 0
for i in range(N):
	if ab[i][1] == skill and f == 0:
		f = 1
		continue
	if ab[i][1] > attack:
		H -= ab[i][1]
		cnt += 1
	if H <= 0:
		print(cnt)
		exit()

if attack < skill:
	H -= skill
	cnt += 1
if H <= 0:
	print(cnt)
else:
	print(cnt + math.ceil(H/attack))

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]
l = sorted(l,key=lambda x:(-x[0],x[1]))
cnt = 0
for i in range(n):
    if i>0 and l[0][0]<=l[i][1]:
        h -= l[i][1]
        cnt += 1
    if h<=0:
        print(cnt)
        exit()
    if h-l[0][1]<=0:
        print(cnt+1)
        exit()
h-=l[0][1]
cnt+=1
if h<=0:
    print(cnt)
elif h%l[0][0]==0:
    print(cnt+h//l[0][0])
else:
    print(cnt+h//l[0][0]+1)

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]
l = sorted(l,key=lambda x:(-x[0],x[1]))
cnt = 0
for i in range(1,n):
    if l[0][0]<=l[i][1]:
        h -= l[i][1]
        cnt += 1
    if h<=0:
        print(cnt)
        exit()
h-=l[0][1]
cnt+=1
if h<=0:
    print(cnt)
elif h%l[0][0]==0:
    print(cnt+h//l[0][0])
else:
    print(cnt+h//l[0][0]+1)

Submission status: Wrong Answer

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

shake = max(a)
b.sort(reverse=True)
ans = 0
if sum(b) < H:
    ans += (H-sum(b))//shake
    ans += 1
    H -= ans * shake
i=0
while H>0:
    ans += 1
    H -= b[i]
    i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#085-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
import math
n,h=IL()
a=0
B=[0]*n
for i in range(n):
    ta,tb=IL()
    a=max(a,ta)
    B[i]=tb
ans=0
for i in range(n):
    if B[-1-i]>=a and h>0:
        h-=B[-1-i]
        ans+=1
    else:
        break
if h>0:
    ans+=math.ceil(h/a)
print(ans)

Submission status: Wrong Answer

Solution code:
def ceil(x,y):
    if x%y==0:
        return x//y
    return x//y+1
n,h=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
max_a=ab[0][0]
ab.sort(key=lambda x:x[1],reverse=True)
c=0
for i in range(n):
    if ab[i][1]>max_a and ab[i][0]!=max_a:
        c+=1
        h-=ab[i][1]
    if h<=0:
        break
if max_a <ab[0][1] and h>0:
   c+=1
   h-=ab[0][1]
c+=ceil(h,max_a) if h>0 else 0
print(c)

Submission status: Wrong Answer

Solution code:
def ceil(x,y):
    if x%y==0:
        return x//y
    return x//y+1
n,h=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
c=0
for i in range(1,n):
    if ab[i][1]>ab[0][0]:
        c+=1
        h-=ab[i][1]
    if h<=0:
        break
if ab[0][0] <ab[0][1]:
   c+=1
   h-=ab[0][1]
c+=ceil(h,ab[0][0]) if h>0 else 0
print(c)

Submission status: Wrong Answer

Solution code:
n, h = map(int, input().split())
amax = 0
bl = []
for i in range(n):
    a, b = map(int, input().split())
    amax = max(amax, a)
    bl.append(b)
bl.sort()
bl.reverse()

ans = 0
for i in range(n):
    if h < 0:
        break
    if bl[i] <= amax:
        break
    ans += 1
    h -= bl[i]
if h > 0:
    ans += h // amax
    h -= (h // amax) * amax
if h > 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, h = map(int, input().split())
amax = 0
bl=[]
for i in range(n):
    a, b = map(int, input().split())
    amax = max(amax, a)
    bl.append(b)
bl.sort()
bl.reverse()

ans = 0
for i in range(n):
    if h == 0:break
    if bl[i] <= amax: break
    ans += 1
    h -= bl[i]
if h > 0:
    ans += h // amax
    h -= (h // amax) * amax
if h > 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n, h = map(int, input().split())
amax = 0
bl=[]
for i in range(n):
    a, b = map(int, input().split())
    amax = max(amax, a)
    bl.append(b)
bl.sort()
bl.reverse()

ans = 0
for i in range(n):
    if h == 0:break
    if bl[i] <= amax: break
    ans += 1
    h -= bl[i]
if h > 0:
    h -= h // amax
    ans += h // amax
    if h > 0:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

a = []
b = []

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

a.sort(reverse=True)
b.sort(reverse=True)
a_max = a[0]

b_nage = [i for i in b if i>a_max]

count = 0
for i in b_nage:
    h -= i
    count += 1
    if h<=0:
        print(count)

count += -(-h//a_max)

print(count)

Submission status: Wrong Answer

Solution code:
import math

n, h = [int(i) for i in input().split(" ")]
t = []

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

t = sorted(t, key=lambda k: k[0], reverse=True)

print(t)

c = 0
i = 0

while h > 0:
    if t[i][1] == "b":
        h -= t[i][0]
        c += 1
        i += 1
    else:
        c += math.ceil(h / t[i][0])
        h = 0

print(c)

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())
    ma = 0
    B = []
    for _ in range(N):
        a, b = map(int, input().split())
        ma = max(ma, a)
        B.append(b)
    B.sort(reverse=True)
    ans = 0
    for b in B:
        if ma >= b or 0 >= H:
            break
        H -= b
        ans += 1
    ans += H // ma
    if H % ma != 0:
        ans += 1
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
from math import ceil

n, h = map(int, input().split())
ab = [[int(x) for x in input().split()] for y in range(n)]
ab_array = []
for a, b in ab:
    ab_array.append([a, "a"])
    ab_array.append([b, "b"])
ab_array = sorted(ab_array, key=lambda x:x[0], reverse=True)
a_max = ab_array[0][0]


cnt = 0
damage = 0
for value, katana in ab_array:
    if h < 0:
        print(cnt)
        exit()
    if katana == "a":
        cnt += ceil(h/value)
        break
    else:
        h -= value
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())

    A = [-1] * N
    B = [-1] * N
    for n in range(N):
        a, b = map(int, input().split())
        A[n] = a
        B[n] = b
    
    B.sort(reverse=True)
    max_A = max(A)
    
    count = 0
    for b in B:
        if max_A < b:
            H -= b
            count += 1
        else:
            break
    return (H - 1) // max_A + 1 + count

print(main())

Submission status: Wrong Answer

Solution code:
from math import ceil

n, h = map(int, input().split())
ab = [[int(x) for x in input().split()] for y in range(n)]
ab_array = []
for a, b in ab:
    ab_array.append([a, "a"])
    ab_array.append([b, "b"])
ab_array = sorted(ab_array, key=lambda x:x[0], reverse=True)
a_max = ab_array[0][0]


cnt = 0
damage = 0
for value, katana in ab_array:
    if katana == "a":
        cnt += ceil(h/value)
        break
    else:
        h -= value
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(n)]
AB.sort(reverse=True)
weapon = []
x = AB[0][0]
for a,b in AB[1:]:
	if b >= x:
		weapon.append(b)
weapon.sort(reverse=True)
weapon.append(x)
weapon.append(AB[0][1])
cnt = 0
for w in weapon[:-2]:
	h -= w
	cnt += 1
	if h <= 0:
		print(cnt)
		exit()
h -= weapon[-1]
cnt += 1
if h <= 0:
	print(cnt)
	exit()
from math import ceil
cnt += ceil(h/weapon[-2])
print(cnt)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import math


def solve(a,b,h):
  ret = 0
  for i in b:
    if h <= 0:
      return ret
    if a < i:
      ret += 1
      h -= i
  ret += math.ceil(h/a)
  return ret


n,h = map(int, input().split())
mx_a = 0
b = [0 for i in range(n)]
for i in range(n):
  a, b[i] = map(int, input().split())
  mx_a = max(mx_a, a)


print(solve(mx_a,b,h))

Submission status: Wrong Answer

Solution code:
from sys import exit
from math import floor
N,H = [int(n) for n in input().split()]
ab = [(0,0)]*N
maxa = 0#振る最大値
ans = 0
for i in range(N):
    ab[i] = tuple(int(n) for n in input().split())
    maxa = max(maxa, ab[i][0])
ab = sorted(ab,key= lambda x:-x[1])
for katana in ab:
    if katana[1] > maxa:
        H-=katana[1]
        ans+=1
        if(H<=0): break
    else:
        break

if(H<=0):
    print(ans)
else:
    print(ans + floor(H/maxa))

Submission status: Wrong Answer

Solution code:
import bisect

n, h = [int(item) for item in input().split()]

a_s, b_s = [], []
for i in range(n):
    a, b = [int(item) for item in input().split()]
    a_s.append(a)
    b_s.append(b)
    
a_s.sort()
b_s.sort()
throwable = bisect.bisect(b_s, a_s[-1])
throw_sum = sum(b_s[throwable:])

ans = (h - throw_sum) // a_s[-1] + len(b_s[throwable:])
if (h - throw_sum) % a_s[-1] != 0:
    ans += 1
if ans <= 0:
    ans = 1
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

n, h = [int(item) for item in input().split()]

a_s, b_s = [], []
for i in range(n):
    a, b = [int(item) for item in input().split()]
    a_s.append(a)
    b_s.append(b)
    
a_s.sort()
b_s.sort()
throwable = bisect.bisect(b_s, a_s[-1])
throw_sum = sum(b_s[throwable:])

ans = (h - throw_sum) // a_s[-1] + len(b_s[throwable:])
if (h - throw_sum) % a_s[-1] != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, y = [int(item) for item in input().split()]
a, b, c = 0, 0, 0
bills = y // 1000
a = bills

while a >= 0:
    if (bills - n) % 4 == 0: 
        b = (bills - n) // 4
        check_a = a-(b*5)
        if check_a+b+c == n and b>=0:
            print(c, b, check_a)
            exit()
    c += 1
    a -= 10
    bills -= 9
print(-1, -1, -1)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>=ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
if H<=0:
  print(c)
  exit()
c+=-(-H//ax)
print(c)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
print(l,l[:-1])
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>=ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
print(c,H)
if H<=0:
  print(c)
  exit()
c+=-(-H//ax)
print(c)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
print(c,H)
if H<=0:
  print(c)
  exit()
c+=(H//ax)
print(c+1)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
if H<=0:
  print(c)
  exit()
c+=-(-H//ax)
print(c+1)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
if H<=0:
  print(c)
  exit()
c+=-(-H//ax)
print(c-1)

Submission status: Wrong Answer

Solution code:
N,H=map(int,input().split())
if N==1 and H==10:
  exit()
l=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append([a,b])
l=sorted(l,key=lambda x:x[0])
ax=l[-1][0]
bx=l[-1][1]
c=0
for x in l[:-1]:
  if H<=bx:
    c+=1
    print(c)
    exit()
  if x[1]>ax:
    H-=x[1]
    c+=1
H-=bx
c+=1
if H<=0:
  print(c)
  exit()
c+=-(-H//ax)
print(c)

Submission status: Wrong Answer

Solution code:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b >= a) & (h > 0):
        h -= b
        count += 1
count += h // a
if h % a != 0:
    count += 1
#output
print(count)

Submission status: Wrong Answer

Solution code:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b >= a) & (h > 0):
        h -= b
        count += 1
count += (h + a - 1) // a
#output
print(count)

Submission status: Wrong Answer

Solution code:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
count += (h + a - 1) // a
#output
print(count)

Submission status: Wrong Answer

Solution code:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if b < a:
        break
    h -= b
    count += 1
    if h <= 0:
        break
count += (h + a - 1) // a
#output
print(count)

Submission status: Wrong Answer

Solution code:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if b < a:
        count += (h + a - 1) // a
        break
    h -= b
    count += 1
    if h <= 0:
        break
#output
print(count)

Submission status: Wrong Answer

Solution code:
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    h -= b
    count += 1
    if h <= 0:
        break
    if b < a:
        count += (h + a - 1) // a
        break
#output
print(count)

Submission status: Wrong Answer

Solution code:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    h -= b
    count += 1
    if b < a:
        break
count += (h + a - 1) // a
#output
print(count)

Submission status: Wrong Answer

Solution code:
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort(reverse=True)
B.sort(reverse=True)
ans = 0

for b in B:
    if b>A[0] and H>0:
        H -= b
        ans += 1

if H > 0:
    ans += (H//A[0])

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n,h = map(int,input().split())

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

maxFuru = max(list(zip(*info))[0])

nageru = []
for i in range(n):
  if info[i][1] > maxFuru:
    nageru.append(info[i][1])
nageru = sorted(nageru)

nokori = h
ans = 0

while nokori>0:
  if nageru:
    nokori -= nageru[-1]
    del nageru[-1]
    ans += 1
  else:
    ans += -(-nokori)//maxFuru
    nokori = 0

print(ans)

Submission status: Wrong Answer

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

B.sort(reverse = True)
maxA = max(A)
cnt = 0
for b in B:
    if b > maxA and H > 0:
        H -= b
        cnt += 1
        
cnt += - (- H // maxA)

print(cnt)

Submission status: Wrong Answer

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

maxA = max(A)
cnt = 0
for b in B:
    if b > maxA and H > 0:
        H -= b
        cnt += 1
        
if H > 0:
    cnt += - (- H // maxA)

print(cnt)

Submission status: Wrong Answer

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

maxA = max(A)
cnt = 0
for b in B:
    if b > maxA:
        H -= b
        cnt += 1
        
cnt += - (- H // maxA)

print(cnt)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=max(a,key=lambda x:x[0])[0]
c=sorted(t for(s,t)in a if t>b)
d=0
while h>0 and c:
    h-=c.pop()
    d+=1
print(d+(h-1)//b+1)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=max(a,key=lambda x:x[0])[0]
c=sorted(t for(s,t)in a if t>b)[::-1]
d=0
for i in c:
    h-=i
    d+=1
    if h<0:
        print(d)
        exit()
if h>0:
    d+=max(h-1,-1)//b+1
print(d)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=max(a,key=lambda x:x[0])[0]
c=sorted(t for(s,t)in a if t>b)[::-1]
d=0
for i in c:
    h-=i
    d+=1
    if h<0:
        print(d)
        exit()
if h>0:
    d+=(h-1)//b+1
print(d)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
a=sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[1])[::-1]
c=0
b=max(a,key=lambda x:x[0])[0]
for(s,t)in a:
    if b<t:
        h-=t
        c+=1
        if h<0:
            print(c)
            exit()
if h>0:
    c+=(h-1)//b+1
print(c)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
a=sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[1])[::-1]
c=0
b=max(a,key=lambda x:x[0])[0]
for k,(s,t)in enumerate(a):
    if b<t:
        h-=t
        c+=1
    if b>=t or k==n-1:
        c+=(h-1)//b+1
        break
print(c)

Submission status: Wrong Answer

Solution code:
n,h=map(int,input().split())
a=sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[1])[::-1]
c=0
for k,(s,t)in enumerate(a):
    if s<t:
        h-=t
        c+=1
    if k==n-1 or s>=t:
        c+=(h-1)//s+1
        break
print(c)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n, h = LI()
    ab = LIR(n)
    ab.sort(reverse=True)
    amax = ab[0][0]
    ab.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    hp = 0
    for a,b in ab:
        if b <= amax:
            break
        ans += 1
        hp += b
        if hp >= h:
            break
    ans += math.ceil((h-hp)/amax)    
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n, h = LI()
    ab = LIR(n)
    ab.sort(reverse=True)
    amax = ab[0][0]
    ab.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    hp = 0
    for a,b in ab:
        if b <= amax:
            break
        ans += 1
        hp += b
        if hp > h:
            break
    ans += math.ceil((h-hp)/amax)    
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()