AtCoder Beginner Contest 085 - Katana Thrower

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 10
3 5

-----Sample Output-----
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.

Difficulty: MEDIUM

Starter code:

Solutions:
(n, h) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
b = [ab[i][1] for i in range(n)]
b.sort(reverse=True)
cnt = 0
ab.sort(key=lambda x: x[0], reverse=True)
k = 0
while k < n and ab[0][0] < b[k] and (h > 0):
	h -= b[k]
	k += 1
	cnt += 1
if h > 0:
	cnt += (h + ab[0][0] - 1) // ab[0][0]
print(cnt)


from math import ceil
(n, h) = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]
max_a = max([lst[i][0] for i in range(n)])
b = sorted((lst[i][1] for i in range(n))) + [0]
for i in range(n - 1, -1, -1):
	b[i] += b[i + 1]
ans = 10 ** 10
for i in range(n + 1):
	hp = h - b[i]
	t = max(0, ceil(hp / max_a))
	t += n - i
	ans = min(ans, t)
print(ans)


import sys
(N, H) = map(int, sys.stdin.readline().split())
katanas = []
for i in range(N):
	(a, b) = map(int, sys.stdin.readline().split())
	katanas.append((a, b, i))
sk = sorted(katanas, reverse=True)
max_k = sk[0][0]
katanas.sort(key=lambda x: x[1], reverse=True)
ans = 0
i = 0
while H > 0:
	if i < N and katanas[i][1] > max_k:
		H -= katanas[i][1]
		i += 1
		ans += 1
	else:
		tmp = (H - 1) // max_k + 1
		H -= tmp * max_k
		ans += tmp
print(ans)


import math
(n, h) = map(int, input().split())
A = [0] * n
B = [0] * (n + 1)
for i in range(n):
	(A[i], B[i]) = map(int, input().split())
a = max(A)
B.sort(reverse=True)
cnt = 0
while h > 0:
	if a > B[0]:
		cnt += math.ceil(h / a)
		h -= math.ceil(math.ceil(h / a) * a)
	else:
		cnt += 1
		h -= B[0]
		B.pop(0)
print(cnt)


(N, H) = (int(i) for i in input().split())
ka = []
kb = []
for i in range(N):
	(a, b) = (int(i) for i in input().split())
	ka.append(a)
	kb.append(b)
kb.sort()
kb.reverse()
ma = max(ka)
hp = H
res = 0
for b in kb:
	if b < ma:
		continue
	hp = hp - b
	res += 1
	if hp <= 0:
		break
else:
	res += (hp + ma - 1) // ma
print(res)


(N, H) = map(int, input().split())
A = []
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
mxA = max(A)
B.sort(reverse=True)
ans = 0
for b in B:
	if b <= mxA or H <= 0:
		break
	H -= b
	ans += 1
if H > 0:
	ans += -(-H // mxA)
print(ans)


(n, h) = map(int, input().split())
(a, b) = ([], [])
for _ in range(n):
	(ai, bi) = map(int, input().split())
	(a.append(ai), b.append(bi))
(a.sort(), b.sort())
(ans, amax) = (0, a[-1])
for bi in b[::-1]:
	if bi <= amax or h <= 0:
		break
	h -= bi
	ans += 1
mod = (h + amax - 1) // amax
print(ans + mod if h > 0 else ans)


import heapq as hq
from itertools import accumulate
from math import ceil
(N, H) = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
ab.sort(key=lambda x: x[1], reverse=True)
ab.sort(key=lambda x: x[0], reverse=True)
(ma, mb) = ab[0]
q = [ab[i][1] for i in range(1, N)]
q.sort(reverse=True)
ans = float('inf')
acc = [0] + list(accumulate(q, lambda x, y: x + y))
for l in range(len(q) + 1):
	h = H
	cnt = l
	h -= acc[l]
	if h <= 0:
		ans = min(ans, cnt)
		continue
	h -= mb
	cnt += 1
	if h <= 0:
		ans = min(ans, cnt)
		continue
	cnt += ceil(h / ma)
	ans = min(ans, cnt)
print(ans)


(n, h) = map(int, input().split())
(a, b) = ([], [])
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
max_a = max(a)
b.sort(reverse=True)
cnt = 0
for i in range(n):
	if b[i] < max_a:
		break
	h -= b[i]
	cnt += 1
	if h <= 0:
		break
if h > 0:
	cnt += (h - 1) // max_a + 1
print(cnt)


import sys
import math
(N, H) = [int(x) for x in input().split()]
A = []
B = []
for _ in range(N):
	(a, b) = [int(x) for x in input().split()]
	A.append(a)
	B.append(b)
B.sort(reverse=True)
max_a = max(A)
cnt = 0
for b in B:
	if b < max_a:
		break
	H -= b
	cnt += 1
	if H <= 0:
		print(cnt)
		return
cnt += int(math.ceil(H / max_a))
print(cnt)


(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
m = max(a)
b.sort()
c = 0
while h > 0:
	if b and b[-1] > m:
		c += 1
		h -= b.pop()
	else:
		c -= h // -m
		h = 0
print(c)


from math import ceil
(N, H) = map(int, input().split())
B = []
maxa = 0
cnt = 0
for i in range(N):
	(a, b) = map(int, input().split())
	maxa = max(maxa, a)
	B.append(b)
B.sort(reverse=True)
for i in range(N):
	if B[i] < maxa:
		break
	cnt += 1
	H -= B[i]
	if H <= 0:
		print(cnt)
		exit(0)
cnt += ceil(H / maxa)
print(cnt)


(n, h, *A) = map(int, open(0).read().split())
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
	if h <= 0:
		n = i
		h = 0
		break
	if b[i] < a:
		n = i
		break
	h -= b[i]
print(n - -h // a)


(N, H) = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
A = int(max(a))
B = [i for i in b if i > A]
B.sort(reverse=True)
Sum = 0
for i in range(len(B)):
	H -= B[i]
	Sum += 1
	if H <= 0:
		break
if H > 0:
	Sum += int((H - 1) // A) + 1
print(Sum)


(n, h) = map(int, input().split())
A = 0
B = []
for _ in range(n):
	(a, b) = map(int, input().split())
	if A < a:
		A = a
	B.append(b)
B.sort(reverse=True)
cnt = 0
for i in B:
	if A < i:
		h -= i
		cnt += 1
	if h <= 0:
		print(cnt)
		exit()
print(cnt + (h + A - 1) // A)


import sys
(n, h) = map(int, input().split())
a = [list(map(int, x.split())) for x in sys.stdin.readlines()]
a.sort(reverse=True)
b = sorted(a, key=lambda x: x[1], reverse=True)
cnt = 0
for i in b:
	if i[1] < a[0][0]:
		break
	cnt += 1
	h -= i[1]
	if h <= 0:
		print(cnt)
		exit()
print(cnt + -(-h // a[0][0]))


(n, h) = list(map(int, input().split()))
aa = []
bb = []
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	aa.append(a)
	bb.append(b)
maxa = max(aa)
bb.sort(reverse=True)
nage = 0
ch = 0
for i in range(n):
	if bb[i] >= maxa:
		nage += bb[i]
		ch += 1
	else:
		break
if h > nage:
	rest = h - nage
	ch1 = 0
	if rest % maxa == 0:
		ch1 += rest // maxa
	else:
		ch1 += rest // maxa + 1
	print(ch1 + ch)
else:
	ans = 0
	hp = 0
	for j in range(n):
		if hp >= h:
			break
		else:
			ans += 1
			hp += bb[j]
	print(ans)


import sys
read = sys.stdin.read

def main():
	(n, h, *ab) = map(int, read().split())
	tops = max(ab[0::2])
	tlst = [b for b in ab[1::2] if b > tops]
	tlst.sort(reverse=True)
	i = -1
	t = 0
	for (i, t) in enumerate(tlst):
		h -= t
		if h <= 0:
			h = 0
			break
	print(h // tops + (h % tops > 0) + i + 1)
main()


(n, h, *ab) = map(int, open(0).read().split())
a_max = max(ab[::2])
b_sort = sorted(ab[1::2], reverse=True)
ans = 0
i = 0
while h > 0:
	if i < n and b_sort[i] > a_max:
		h -= b_sort[i]
		i += 1
		ans += 1
	else:
		ans += -(-h // a_max)
		h = 0
print(ans)


import sys
(n, h) = map(int, input().split())
max_a = 0
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	max_a = max(max_a, x)
	b.append(y)
b = [x for x in b if x > max_a]
b.sort(reverse=True)
i = 0
if len(b) > 0:
	for (i, x) in enumerate(b):
		i += 1
		h -= x
		if h <= 0:
			print(i)
			return
print((h + max_a - 1) // max_a + i)


(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)
C = []
B.sort(reverse=True)
ans = 0
for ele in B:
	if ele < maxa:
		break
	ans += 1
	h -= ele
	if h <= 0:
		break
if h > 0:
	ans += (h + maxa - 1) // maxa
print(ans)


import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST():
	return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
(N, H) = MAP()
(A, B) = ([], [])
for i in range(N):
	(a, b) = MAP()
	A.append(a)
	B.append(b)
max_a = max(A)
B = sorted(B, reverse=True)
ans = 0
for i in range(N):
	if max_a >= B[i]:
		ans += -(-H // max_a)
		H = 0
	else:
		H -= B[i]
		ans += 1
	if H <= 0:
		print(ans)
		break
if H > 0:
	ans += -(-H // max_a)
	print(ans)


import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop
INPUT = lambda : sys.stdin.readline().rstrip()
INT = lambda : int(INPUT())
MAP = lambda : list(map(int, INPUT().split()))
S_MAP = lambda : list(map(str, INPUT().split()))
LIST = lambda : list(map(int, INPUT().split()))
S_LIST = lambda : list(map(str, INPUT().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	(N, H) = MAP()
	(A, B) = ([0] * N, [0] * N)
	for i in range(N):
		(A[i], B[i]) = MAP()
	MAX_A = max(A)
	B.sort(reverse=True)
	ans = 0
	for i in range(N):
		if MAX_A >= B[i]:
			ans += -(-H // MAX_A)
			print(ans)
			break
		else:
			H -= B[i]
			ans += 1
		if H <= 0:
			print(ans)
			break
	else:
		ans += -(-H // MAX_A)
		print(ans)

def __starting_point():
	main()
__starting_point()


import sys
input = sys.stdin.readline
(n, hp) = map(int, input().split())
(ata, sute) = zip(*[tuple(map(int, input().split())) for i in range(n)])
ata = max(ata)
sute = sorted(list(sute), reverse=1)
ans = float('inf')
for i in range(n):
	hp -= sute[i]
	ans = min(ans, -(-max(0, hp) // ata) + i + 1)
print(ans)


import sys
(N, H) = map(int, input().split())
A = 0
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A = max(A, a)
	B.append(b)
B.sort(reverse=True)
ans = 0
for b in B:
	if b > A:
		H -= b
		ans += 1
	else:
		break
	if H <= 0:
		print(ans)
		sys.exit()
print((H - 1) // A + 1 + ans)


(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)
am = max(A)
pop = []
for i in reversed(range(N)):
	if B[i] < am:
		B.pop(i)
		A.pop(i)
n = 0
for i in reversed(sorted(B)):
	if H <= 0:
		print(n)
		exit()
	else:
		n += 1
		H -= i
print((H - 1) // am + 1 + n)


f = lambda : [*map(int, input().split())]
(n, h) = f()
(A, B) = ([], [])
for _ in range(n):
	(a, b) = f()
	A += [a]
	B += [b]
m = max(A)
B.sort()
c = 0
while h > 0 and B and (B[-1] > m):
	h -= B.pop()
	c += 1
print(c - -h // m * (h > 0))


(N, H) = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
a = max(A)
B.sort()
ans = 0
while len(B) > 0 and B[-1] >= a and (H > 0):
	H -= B.pop()
	ans += 1
	if H <= 0:
		print(ans)
		exit()
print(ans + -(-H // a))


import bisect
(N, H) = list(map(int, input().split()))
B = [0] * N
m = 0
for i in range(N):
	(a, b) = list(map(int, input().split()))
	B[i] = b
	m = max(m, a)
B = sorted(B)
index = bisect.bisect_left(B, m)
over = sum(B[index:])
if over >= H:
	now = 0
	i = 1
	while now < H:
		now += B[-i]
		i += 1
	print(i - 1)
else:
	H -= over
	ans = N - index
	ans += int(H / m)
	if H % m != 0:
		ans += 1
	print(ans)


import math
(n, h) = map(int, input().split())
a = sorted([list(map(int, input().split())) for i in range(n)], key=lambda x: x[1])[::-1]
r = 0
d = 0
p = 0
k = float('inf')
while p < n:
	r += a[p][1]
	d = max(d, a[p][0])
	k = min(k, p + 1 + math.ceil(max(0, h - r) / d))
	p += 1
	if r >= h:
		break
print(k)


(n, h) = map(int, input().split())
p = []
for i in range(n):
	(a, b) = map(int, input().split())
	p.append([a, 0])
	p.append([b, 1])
p = sorted(p, key=lambda x: -x[0])
i = 0
ans = 0
while h > 0:
	if p[i][1] == 1:
		h -= p[i][0]
		ans += 1
		i += 1
	else:
		ans -= -h // p[i][0]
		break
print(ans)


import sys
input = sys.stdin.readline
(n, h) = map(int, input().split())
(a, b) = ([0] * n, [0] * n)
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
a_max = max(a)
b_thr = []
for i in b:
	if i > a_max:
		b_thr.append(i)
b_thr.sort(reverse=True)
ans = 0
for i in b_thr:
	if h > 0:
		h -= i
		ans += 1
	else:
		print(ans)
		return
if h % a_max == 0:
	ans += h // a_max
else:
	ans += h // a_max + 1
print(ans)


(n, h) = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
AB = sorted(AB, key=lambda x: x[1])
ans = 0
a = sorted(AB)[-1][0]
for i in range(len(AB)):
	if len(AB) <= 0 or h <= 0:
		break
	b = AB.pop(-1)[1]
	h -= b if b > a else a
	ans += 1
if h > 0:
	ans += (h + a - 1) // a
print(ans)


from math import ceil
(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
dmax = max(a)
b.sort(reverse=True)
ans = 0
for d in b:
	if h <= 0:
		print(ans)
		exit()
	if d < dmax:
		break
	h -= d
	ans += 1
if h <= 0:
	print(ans)
	exit()
print(ans + ceil(h / dmax))


import math
(n, h) = map(int, input().split(' '))
abL = [list(map(int, input().split(' '))) for _ in range(n)]
aL = []
bL = []
for (a, b) in abL:
	aL.append(a)
	bL.append(b)
aL = sorted(aL)
bL = sorted(bL)
aMax = max(aL)
ans = 0
while h != 0:
	if h <= 0:
		break
	if len(bL) == 0 or bL[-1] < aMax:
		ans += math.ceil(h / aMax)
		break
	ans += 1
	h -= bL.pop()
print(ans)


(n, h) = map(int, input().split())
power = [list(map(int, input().split())) for _ in range(n)]
maxa = sorted(power, key=lambda x: x[0], reverse=True)[0][0]
muscleb = sorted(list(filter(lambda x: x[1] >= maxa, power)), key=lambda x: x[1], reverse=True)
ans = 0
for m in muscleb:
	ans += 1
	h -= m[1]
	if h <= 0:
		print(ans)
		return
additionala = h // maxa
if h % maxa != 0:
	additionala += 1
print(additionala + ans)


(n, h, *d) = map(int, open(0).read().split())
a = max(d[::2])
b = sorted(d[1::2])
c = 0
while b and b[-1] > a > 0 < h:
	h -= b.pop()
	c += 1
print(c - -h * (h > 0) // a)


(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 = max(A)
B.sort(reverse=True)
count = 0
for i in B:
	if A > i:
		break
	elif h > 0:
		h -= i
		count += 1
	else:
		break
if h % A == 0 and h > 0:
	print(count + h // A)
elif h % A != 0 and h > 0:
	print(count + h // A + 1)
else:
	print(count)


(n, h, *l) = map(int, open(0).read().split())
a = max(l[::2])
c = 0
f = 1
for b in sorted(l[1::2])[::-1]:
	if b > a:
		h -= b
		c += 1
		if h < 1:
			f = 0
			break
print(c + (~-h // a + 1) * f)


(n, h) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	(j, k) = map(int, input().split())
	a.append(j)
	b.append(k)
am = max(a)
bm = []
for i in b:
	if am < i:
		bm.append(i)
if sum(bm) < h:
	print(len(bm) + (h - sum(bm) + am - 1) // am)
else:
	bm.sort()
	ans = 0
	while h > 0:
		h -= bm.pop(-1)
		ans += 1
	print(ans)


(N, H) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in [0] * N]
a = max([a for (a, b) in ab])
b = sorted([b for (_, b) in ab if b > a])[::-1]
s = sum(b)
if s >= H:
	while s >= H:
		s -= b.pop()
	ans = len(b) + 1
else:
	ans = (H - s - 1) // a + 1 + len(b)
print(ans)


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


(n, h) = list(map(int, input().split()))
b = []
t = []
for _ in range(n):
	(c, d) = list(map(int, input().split()))
	b.append(c)
	t.append(d)
b_max = max(b)
t = sorted(t)
from bisect import bisect_right
from math import ceil
index = bisect_right(t, b_max)
ans = 0
for i in range(n - 1, index - 1, -1):
	h -= t[i]
	ans += 1
	if h <= 0:
		print(ans)
		return
cnt = ceil(h / b_max)
print(ans + cnt)


(n, h) = map(int, input().split())
(a, b) = zip(*(tuple(map(int, input().split())) for _ in range(n)))
m = max(a)
c = 0
for v in sorted(b)[::-1]:
	if h <= 0 or v < m:
		break
	h -= v
	c += 1
print(c + (max(0, h) + m - 1) // m)


(n, H) = list(map(int, input().split()))
a = []
b = []
for i in range(n):
	(ai, bi) = list(map(int, input().split()))
	a.append(ai)
	b.append(bi)
ans = 0
amax = max(a)
b.sort(reverse=True)
i = 0
while H > 0:
	if i < n:
		if amax < b[i]:
			H -= b[i]
			ans += 1
			i += 1
		else:
			ans += H // amax
			if H % amax != 0:
				ans += 1
			break
	else:
		ans += H // amax
		if H % amax != 0:
			ans += 1
		break
print(ans)


(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = 0
j = 0
while j < n:
	if b[j] > a[0]:
		c += b[j]
	else:
		break
	j += 1
	if c >= h:
		break
if c < h:
	j += -(-(h - c) // a[0])
print(j)


(N, H) = map(int, input().split(' '))
a = [0] * N
b = [0] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split(' '))
a.sort(reverse=True)
b.sort(reverse=True)
c = 0
while b[c] > a[0]:
	H -= b[c]
	c += 1
	if c == len(b):
		break
	if H <= 0:
		break
if H > 0:
	if H % a[0] != 0:
		c += 1
	c += H // a[0]
print(c)


(n, h) = list(map(int, input().split()))
atk = []
ans = 0
for i in range(n):
	(a, b) = list(map(int, input().split()))
	atk.append((a, 0))
	atk.append((b, 1))
atk.sort(key=lambda x: x[0], reverse=True)
for blade in atk:
	if blade[1] == 0:
		break
	else:
		h = max(0, h - blade[0])
		ans += 1
		if h <= 0:
			break
print(ans - -h // blade[0])


(n, h) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
max_a = max(l, key=lambda x: x[0])[0]
l = [[a, b] for (a, b) in l if b > max_a]
l.sort(key=lambda x: x[1], reverse=True)
c = 0
for (a, b) in l:
	h -= b
	c += 1
	if h <= 0:
		print(c)
		exit()
print(c + h // max_a + (h % max_a != 0))


(n, h, *d) = map(int, open(0).read().split())
a = max(d[::2])
b = sorted((b for b in d[1::2] if b >= a))[::-1]
i = 0
for b in b:
	h -= b
	i += 1
	if h <= 0:
		print(i)
		exit()
print(i + 0 - -h // a)


(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
A = max(a)
B = sorted([x for x in b if x > A], reverse=True)
cnt = 0
damage = 0
for b in B:
	cnt += 1
	damage += b
	if damage >= h:
		break
else:
	cnt += -(-(h - damage) // A)
print(cnt)


(N, H) = map(int, input().split())
A = 0
B = [0] * (N + 1)
for i in range(N):
	(a, b) = map(int, input().split())
	A = max(a, A)
	B[i] = b
B.sort(reverse=True)
cnt = 0
i = 0
while H > 0:
	if B[i] > A:
		H -= B[i]
		cnt += 1
		i += 1
	else:
		k = -(-H // A)
		H -= A * k
		cnt += k
print(cnt)


(N, H) = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
A = max((a for (a, _) in L))
B = sorted((b for (_, b) in L if b > A))
M = len(B)
while B and H > 0:
	H -= B.pop()
print(M - len(B) + max(-1, H - 1) // A + 1)


(N, H) = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
b.sort(reverse=True)
maxa = max(a)
ans = 0
for i in range(N):
	if b[i] < maxa:
		break
	if H <= 0:
		break
	H -= b[i]
	ans += 1
if H > 0:
	ans += -(-H // maxa)
print(ans)


import bisect
(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 = sorted(b)
nage = b[bisect.bisect_right(b, max(a)):]
ans = 0
for i in nage[::-1]:
	h -= i
	ans += 1
	if h <= 0:
		break
ans += max(-(-h // max(a)), 0)
print(ans)


(N, H) = map(int, input().split())
A = []
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
B.sort(reverse=True)
Amax = max(A)
cnt = 0
for b in B:
	if Amax <= b:
		H -= b
		cnt += 1
		if H <= 0:
			print(cnt)
			exit()
print((H - 1) // Amax + 1 + cnt)


import sys
import math
(N, H) = map(int, input().split())
p = []
x = [list(map(int, input().split())) for i in range(N)]
a = max((x[i][0] for i in range(N)))
for i in range(N):
	if x[i][1] > a:
		p.append(x[i][1])
p.sort(reverse=True)
for i in range(len(p)):
	H -= p[i]
	if H <= 0:
		(print(i + 1), sys.exit())
print(len(p) + math.ceil(H / a))


(n, h) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(reverse=True, key=lambda x: x[1])
a_max = 0
for (a, b) in ab:
	a_max = max(a, a_max)
cnt = 0
damage = 0
for (a, b) in ab:
	if damage >= h:
		print(cnt)
		exit()
	if b <= a_max:
		break
	cnt += 1
	damage += b
zan = h - damage
cnt += (zan + a_max - 1) // a_max
print(cnt)


(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)
A.sort(reverse=True)
B.sort(reverse=True)
B = [i for i in B if i > A[0]]
ans = 0
for i in B:
	ans += 1
	h -= i
	if h <= 0:
		break
if h > 0:
	if h % A[0] == 0:
		ans += h // A[0]
	else:
		ans += h // A[0] + 1
print(ans)


(N, H) = map(int, input().split())
src = [tuple(map(int, input().split())) for i in range(N)]
maxa = max(src)[0]
ans = 0
for (a, b) in sorted(src, key=lambda x: x[1], reverse=True):
	if b <= maxa:
		break
	H -= b
	ans += 1
	if H <= 0:
		print(ans)
		exit()
ans += (H - 1) // maxa + 1
print(ans)


(N, H) = list(map(int, input().split()))
a = 0
b = [0]
for i in range(N):
	A = list(map(int, input().split()))
	a = max(a, A[0])
	b += [A[1]]
b = sorted(b)[::-1]
for i in range(N + 1):
	if H <= 0:
		break
	if b[i] > a:
		H -= b[i]
	else:
		i += int(H / a) + (0 != H % a)
		break
print(i)


(N, H) = map(int, input().split())
X = [tuple(map(int, input().split())) for i in range(N)]
A = [x[0] for x in X]
B = [x[1] for x in X]
amax = max(A)
B.sort(reverse=True)
ans = 0
for b in B:
	if H <= 0 or b <= amax:
		break
	if b > amax:
		ans += 1
		H -= b
if H <= 0:
	print(ans)
else:
	ans += (H + amax - 1) // amax
	print(ans)


from math import *
(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)
aa = max(a)
b.sort(reverse=True)
ans = 0
for i in range(n):
	if b[i] > aa:
		h -= b[i]
		ans += 1
		if h <= 0:
			print(ans)
			exit()
print(ans + ceil(h / aa))


(N, H) = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
(a, b) = zip(*((a, b) for (a, b) in X))
am = max(a)
b = sorted(b, reverse=True)
ans = 0
h = H
for v in b:
	if v > am:
		h -= v
		ans += 1
	if h <= 0:
		break
if h > 0:
	ans += -(-h // am)
print(ans)


(n, h) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
attack = max(AB)[0]
AB = sorted(AB, reverse=True, key=lambda x: x[1])
cnt = 0
for (i, j) in AB:
	if j >= attack:
		h -= j
		cnt += 1
	if h <= 0:
		print(cnt)
		exit()
print(cnt + h // attack if h % attack == 0 else cnt + h // attack + 1)


throw = []
blow = 0
cnt = 0
(n, h) = map(int, input().split())
for _ in range(n):
	(a, b) = map(int, input().split())
	blow = max(blow, a)
	throw.append(b)
throw.sort()
while h > 0 and throw and (throw[-1] > blow):
	h -= throw.pop()
	cnt += 1
if h > 0:
	cnt += h // blow + (h % blow > 0)
print(cnt)


import sys
import math
input = sys.stdin.readline
(n, h) = list(map(int, input().split()))
once = []
infinity = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	once.append(b)
	infinity.append(a)
once.sort(reverse=True)
pin = max(infinity)
once2 = []
for i in range(n):
	if once[i] > pin:
		once2.append(once[i])
	else:
		break
ans = 0
for i in once2:
	ans += 1
	h -= i
	if h <= 0:
		print(ans)
		return
ans += math.ceil(h / pin)
print(ans)


(n, h) = map(int, input().split())
p = []
q = []
for i in range(n):
	(a, b) = map(int, input().split())
	p.append(a)
	q.append(b)
A = max(p)
q.sort(reverse=True)
ans = 0
for i in range(n):
	ans += 1
	h -= max(q[i], A)
	if h <= 0:
		print(ans)
		exit()
ans += -(-h // A)
print(ans)


from math import ceil
(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
b.sort()
b.reverse()
cnt = 0
ma = max(a)
for i in range(n):
	if b[i] > ma:
		h -= b[i]
		cnt += 1
	if h <= 0:
		print(cnt)
		exit()
cnt += ceil(h / ma)
print(cnt)


(N, H) = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
a = max(A)
B.sort()
cnt = 0
for b in B[::-1]:
	if b > a:
		H -= b
		cnt += 1
		if H <= 0:
			break
if H > 0:
	cnt += (H + a - 1) // a
print(cnt)


import math
(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)
A.sort(reverse=True)
B.sort(reverse=True)
a_max = A[0]
ans = 0
bi = 0
while H > 0:
	if bi < N and a_max <= B[bi]:
		ans += 1
		H -= B[bi]
		bi += 1
	else:
		ans += math.ceil(H / a_max)
		break
print(ans)


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
(n, h) = readInts()
A = [0] * n
B = [0] * n
for i in range(n):
	(a, b) = readInts()
	A[i] = a
	B[i] = b
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
MAX = A[0]
ans = 0
for v in B:
	if h <= 0:
		break
	if v > MAX:
		ans += 1
		h -= v
	else:
		break
if h > 0:
	ans += (h + MAX - 1) // MAX
print(ans)


from heapq import heappop, heappush
(n, h) = map(int, input().split())
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	heappush(a, (-x, 1))
	heappush(a, (-y, 0))
ans = 0
while h > 0:
	(x, y) = heappop(a)
	if y:
		ans += (h - x - 1) // -x
		break
	else:
		h += x
		ans += 1
print(ans)


(n, h) = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(n)]
maxa = max(map(lambda x: x[0], ab))
ab.sort(key=lambda x: x[1], reverse=True)
ans = 0
for (a, b) in ab:
	if b > maxa:
		h -= b
		ans += 1
	if h <= 0:
		print(ans)
		exit(0)
print(ans + (h - 1) // maxa + 1)


(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
a.sort()
b.sort()
b.reverse()
c = 0
for x in b:
	if x <= a[-1] or h <= 0:
		break
	h -= x
	c += 1
print(c + max(0, (h + a[-1] - 1) // a[-1]))


import math
(n, h) = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(n)]
a_sort = sorted(lis, reverse=True)
b_sort = sorted(lis, key=lambda x: x[1], reverse=True)
cnt = 0
furu = a_sort[0][0]
for nage in b_sort:
	if nage[1] > furu:
		h -= nage[1]
		cnt += 1
	else:
		break
	if h <= 0:
		break
if h <= 0:
	print(cnt)
else:
	plus = int(math.ceil(h / furu))
	cnt += plus
	print(cnt)


(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.append(0)
a = max(A)
B.sort()
ans = 0
while a <= B[-1] and H > 0:
	b = B.pop()
	H -= b
	ans += 1
H = max(0, H)
last = (H + a - 1) // a
ans += last
print(ans)


(n, h) = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
(a, b) = (0, [])
for j in x:
	if a < j[0]:
		a = j[0]
	b.append(j[1])
b = [i for i in b if i > a]
b.sort()
b = b[::-1]
if h <= sum(b):
	(num, i) = (0, 0)
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h + a - 1) // a + len(b)
print(num)


(n, h) = map(int, input().split())
(A, B) = ([0] * n, [0] * n)
for i in range(n):
	(A[i], B[i]) = map(int, input().split())
A_max = max(A)
B.sort(reverse=True)
ans = 0
for i in B:
	if i > A_max:
		h -= i
		ans += 1
		if h <= 0:
			h = 0
			break
	else:
		break
if h < 0:
	h = 0
q = h / A_max
p = q % 1
ans += int(q)
if p > 0:
	print(ans + 1)
else:
	print(ans)


(N, HP) = map(int, input().split())
As = [0] * N
Bs = [0] * N
for i in range(N):
	(a, b) = map(int, input().split())
	As[i] = a
	Bs[i] = b
As.sort(reverse=True)
Bs.sort(reverse=True)
cnt = 0
for b in Bs:
	if As[0] < b:
		HP -= b
		cnt += 1
	else:
		break
	if HP <= 0:
		break
print(cnt + (HP // As[0] + (HP % As[0] != 0) if HP > 0 else 0))


(n, h) = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
	(ai, bi) = list(map(int, input().split()))
	a[i] = ai
	b[i] = bi
a.sort(reverse=True)
b.sort(reverse=True)
b_select = []
for i in range(n):
	if b[i] < a[0]:
		break
	else:
		b_select.append(b[i])
if sum(b_select) >= h:
	for i in range(n):
		h -= b_select[i]
		if h <= 0:
			break
	counter = i + 1
else:
	h -= sum(b_select)
	counter = len(b_select)
	counter += (h + a[0] - 1) // a[0]
print(counter)


(N, H) = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1], reverse=True)
a_M = max([ab[i][0] for i in range(N)])
ans = 0
for (a, b) in ab:
	if b <= a_M:
		break
	H -= b
	ans += 1
	if H <= 0:
		break
if H > 0:
	ans += (H - 1) // a_M + 1
print(ans)


(n, h) = map(int, input().split())
mxa = 0
dmg = 0
cnt = 0
di = []
for i in range(n):
	(a, b) = map(int, input().split())
	di.append(b)
	if a > mxa:
		mxa = a
di.sort(reverse=True)
for j in di:
	if j >= mxa:
		dmg += j
		cnt += 1
		if dmg >= h:
			break
if dmg < h:
	cnt += (h - dmg) // mxa
	if (h - dmg) % mxa != 0:
		cnt += 1
print(cnt)


(N, H) = map(int, input().split())
A = []
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
B.sort(reverse=True)
ma = max(A)
counter = 0
for b in B:
	if b > ma:
		counter += 1
		H -= b
		if H <= 0:
			print(counter)
			exit()
	else:
		break
counter += (H - 1) // ma + 1
print(counter)


from math import ceil
(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(ai, bi) = map(int, input().split())
	a.append(ai)
	b.append(bi)
ans = 0
maxa = max(a)
b2 = sorted([i for i in b if i > maxa], reverse=True)
for k in b2:
	if h > 0:
		ans += 1
		h -= k
if h > 0:
	ans += ceil(h / maxa)
print(ans)


import bisect
import sys
import math
sys.setrecursionlimit(10 ** 6)
(n, h) = list(map(int, input().split()))
a = []
b = []
ab = []
for i in range(n):
	(a_tmp, b_tmp) = list(map(int, input().split()))
	a.append(a_tmp)
	b.append(b_tmp)
a_max = max(a)
b.sort()
index = bisect.bisect_right(b, a_max)
ans = 0
for i in reversed(list(range(index, n))):
	h -= b[i]
	ans += 1
	if h <= 0:
		break
if h > 0:
	ans += math.ceil(h / a_max)
print(ans)


(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)
MA = max(A)
ans = 0
B.sort()
k = -1
while B[k] > MA:
	H -= B[k]
	k -= 1
	ans += 1
	if H <= 0:
		break
	if k < -N:
		break
if H >= 0:
	ans += -(-H // MA)
print(ans)


(N, H) = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
	(a, b) = map(int, input().split())
	slash = max(slash, a)
	if b > a:
		Throw.append(b)
Throw = sorted([th for th in Throw if th > slash], reverse=True)
(dmg, cnt) = (0, 0)
for throw in Throw:
	if dmg >= H:
		break
	dmg += throw
	cnt += 1
if dmg < H:
	from math import ceil
	cnt += ceil((H - dmg) / slash)
print(cnt)


(N, H) = map(int, input().split())
A = []
B = []
for i in range(N):
	AB = list(map(int, input().split()))
	A.append(AB[0])
	B.append(AB[1])
B.sort(reverse=True)
Amax = max(A)
ans = 0
for i in range(N):
	if B[i] < Amax:
		break
	H -= B[i]
	ans += 1
	if H <= 0:
		break
if H > 0:
	ans = ans + -(-H // Amax)
print(ans)


import math
(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
ans = 0
b.sort(reverse=True)
Am = max(a)
for i in range(n):
	if b[i] >= Am:
		h -= b[i]
		ans += 1
	if h <= 0:
		break
if h > 0:
	ans += math.ceil(h / Am)
print(ans)


import io
import sys
import math
(n, h, *l) = map(int, open(0).read().split())
array = max(l[::2])
c = 0
f = 1
for b in sorted(l[1::2])[::-1]:
	if b > array:
		h -= b
		c += 1
		if h < 1:
			f = 0
			break
print(c + (~-h // array + 1) * f)


def main():
	with open(0) as f:
		(N, H) = list(map(int, f.readline().split()))
		ab = list(map(int, f.read().split()))
	max_slash = max(ab[0::2])
	throw = sorted([x for x in ab[1::2] if x > max_slash], reverse=True)
	cnt = 0
	for t in throw:
		if H <= 0:
			break
		H += -t
		cnt += 1
	if H > 0:
		cnt += (H + max_slash - 1) // max_slash
	print(cnt)
main()


(n, h) = map(int, input().split())
(al, bl) = ([], [])
for i in range(n):
	(a, b) = map(int, input().split())
	al.append(a)
	bl.append(b)
ma = max(al)
bl.sort()
s = 0
c = 0
for i in bl[::-1]:
	if ma >= i:
		break
	else:
		s += i
		c += 1
		if s >= h:
			break
if h > s:
	c += (h - s - 1) // ma + 1
print(c)


(n, h) = map(int, input().split())
x = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append([a, 0])
	x.append([b, 1])
x.sort(reverse=1)
i = ans = 0
while h > 0:
	if x[i][1]:
		h -= x[i][0]
		ans += 1
	else:
		ans += 0 - -h // x[i][0]
		h = 0
	i += 1
print(ans)


(n, h) = map(int, input().split())
(a, b) = ([0] * n, [0] * n)
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
a_max = max(a)
b = sorted(b, reverse=True)
b_throw = [bi for bi in b if bi > a_max]
ans = 0
for k in b_throw:
	h -= k
	ans += 1
	if h <= 0:
		break
if h > 0:
	ans += (h + a_max - 1) // a_max
print(ans)


import sys
import numpy as np
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	(N, H) = inl()
	a = [None] * N
	b = [None] * N
	mi = None
	(ma, mb) = (0, 0)
	for i in range(N):
		(a[i], b[i]) = inl()
		if a[i] > ma:
			mi = i
			ma = a[i]
	bm = max(b[mi], a[mi])
	am = a[mi]
	bb = []
	for i in range(N):
		bb.append((b[i], i))
	bb.sort(reverse=True)
	cnt = 0
	for i in range(N):
		if H <= 0:
			break
		(x, j) = bb[i]
		debug(H, x, j)
		if x < am:
			break
		H -= x
		cnt += 1
	if H > 0:
		k = (H + am - 1) // am
		cnt += k
		H -= k * am
		assert H <= 0
	return cnt
print(solve())


(N, H) = map(int, input().split())
nage = []
a_max = 0
for i in range(N):
	(a, b) = map(int, input().split())
	a_max = max(a_max, a)
	nage.append(b)
nage.sort(reverse=True)
cnt = 0
for i in (i for i in nage if i > a_max):
	cnt += 1
	H -= i
	if H <= 0:
		print(cnt)
		exit()
cnt += -(-H // a_max)
print(cnt)


import math
(N, H) = list(map(int, input().split()))
a_list = []
b_list = []
for _ in range(N):
	(a, b) = list(map(int, input().split()))
	a_list.append(a)
	b_list.append(b)
a_max = max(a_list)
b_list = sorted(b_list, reverse=True)
b_list.append(0)
h = H
ans = 0
for b in b_list:
	if b >= a_max:
		ans += 1
		h -= b
		if h <= 0:
			break
	else:
		ans += math.ceil(h / a_max)
		break
print(ans)


(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 = sorted([b for b in B if b > ma])
ans = 0
while H > 0 and B:
	H -= B.pop()
	ans += 1
if H > 0:
	ans += -(-H // ma)
print(ans)


(n, h) = list(map(int, input().split()))
bi_str = []
a_big = 0
ans = 0
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = list(map(int, input().split()))
	if a[i] > a_big:
		a_big = a[i]
for i in range(n):
	if b[i] > a_big:
		bi_str.append(b[i])
bi_str.sort(reverse=True)
if h <= sum(bi_str):
	for i in bi_str:
		if h > 0:
			h -= i
			ans += 1
		else:
			break
else:
	h -= sum(bi_str)
	ans += len(bi_str)
	ans += -(-h // a_big)
print(ans)


(N, M) = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key=lambda X: -X[0])
a = X[0][0]
X = sorted(X, key=lambda X: -X[1])
i = 0
count = 0
while M > 0:
	if i < N and X[i][1] > a:
		M -= X[i][1]
		i += 1
	else:
		count += -(-M // a)
		break
	count += 1
print(count)


(n, h) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
a_max = max((a for (a, b) in AB))
B = [b for (a, b) in AB if b > a_max]
B.sort(reverse=True)
ans = 0
for b in B:
	if h <= 0:
		break
	ans += 1
	h -= b
if h > 0:
	ans += (h + a_max - 1) // a_max
print(ans)


(N, H) = map(int, input().split())
l = []
A = []
B = []
for i in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
B.sort(reverse=True)
ans = 0
n = max(A)
flag = True
for i in range(N):
	if B[i] > n:
		ans += 1
		H -= B[i]
		if H <= 0:
			flag = False
			break
	else:
		break
if flag:
	ans += H // n
	if H % n != 0:
		ans += 1
print(ans)


import math
(n, h) = map(int, input().split())
max = 0
b = []
c = 0
for i in range(n):
	(a, b1) = map(int, input().split())
	if a > max:
		max = a
	b.append(b1)
b.sort(reverse=True)
b.append(0)
i = 0
while h > 0 and b[i] > max:
	h -= b[i]
	i += 1
	c += 1
if h > 0:
	c += math.ceil(h / max)
print(c)


import math
(N, H) = map(int, input().split())
a_l = []
b_l = []
for _ in range(N):
	(a, b) = map(int, input().split())
	a_l.append(a)
	b_l.append(b)
a_l.sort(reverse=True)
b_l.sort(reverse=True)
ans = 0
for i in range(N):
	if a_l[0] >= b_l[i]:
		break
	else:
		ans += 1
		H = max(H - b_l[i], 0)
		if H <= 0:
			break
ans += math.ceil(H / a_l[0])
print(ans)


import math
(n, h) = map(int, input().split())
alst = []
blst = []
for _ in range(n):
	(a, b) = map(int, input().split())
	alst.append(a)
	blst.append(b)
ma = max(alst)
blst.sort(reverse=True)
ans = 0
for b in blst:
	if b < ma:
		break
	if h <= 0:
		break
	h -= b
	ans += 1
if h > 0:
	ans += math.ceil(h / ma)
print(ans)


def resolve():
	(N, H) = map(int, input().split())
	A = [0] * N
	B = [0] * N
	for i in range(N):
		(a, b) = map(int, input().split())
		A[i] = a
		B[i] = b
	a_max = max(A)
	B = [b for b in B if a_max < b]
	B.sort(reverse=True)
	cnt = 0
	for b in B:
		if H <= 0:
			print(cnt)
			return
		H -= b
		cnt += 1
	cnt += -(-H // a_max)
	print(cnt)

def __starting_point():
	resolve()
__starting_point()


(N, H) = [int(_) for _ in input().split()]
A = []
B = []
for _ in range(N):
	(a, b) = [int(_) for _ in input().split()]
	A.append(a)
	B.append(b)
a = max(A)
cnt = 0
for b in sorted(B, reverse=True):
	if b < a:
		break
	H -= b
	cnt += 1
	if H <= 0:
		print(cnt)
		return
cnt += H // a
if H % a != 0:
	cnt += 1
print(cnt)


(n, h) = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
ans = 0
i = 0
while i < n and a[0] < b[i]:
	h -= b[i]
	i += 1
	ans += 1
	if h <= 0:
		break
if h <= 0:
	print(ans)
else:
	print(ans + (h + a[0] - 1) // a[0])


from math import ceil
import sys
input = sys.stdin.readline
(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(p, q) = map(int, input().split())
	a.append(p)
	b.append(q)
b.sort()
ans = 0
m = max(a)
while h > 0 and len(b) != 0:
	if b[-1] < m:
		break
	h -= b.pop()
	ans += 1
if h > 0:
	ans += ceil(h / m)
print(ans)


import bisect
import math
(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)
am = max(A)
B.sort()
idx = bisect.bisect_right(B, am)
ans = 0
for i in range(1, N - idx + 1):
	H -= B[-i]
	ans += 1
	if H <= 0:
		print(ans)
		return
print(ans + math.ceil(H / am))


(N, H) = list(map(int, input().split()))
maxA = 0
n = 0
b = []
for _ in range(N):
	(ta, tb) = list(map(int, input().split()))
	maxA = max(maxA, ta)
	b.append(tb)
b = list(filter(lambda x: x > maxA, b))
b.sort()
while H > 0 and b:
	H -= b.pop()
	n += 1
print(n + max(H - 1, -1) // maxA + 1)


(N, H) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
(A, B) = zip(*AB)
a = max(A)
B = [b for b in B if b > a]
B.sort(reverse=True)
answer = 0
hp = H
attack_cnt = 0
for b in B:
	if hp <= 0:
		break
	attack_cnt += 1
	hp -= b
if hp > 0:
	attack_cnt += (hp - 1) // a + 1
print(attack_cnt)


(N, H) = map(int, input().split())
a = []
b = []
damege = 0
count = 0
for i in range(N):
	(A, B) = map(int, input().split())
	a.append(A)
	b.append(B)
if N > 1:
	b = sorted(b, reverse=True)
i = 0
A = max(a)
while i < N and b[i] > A and (damege < H):
	damege += b[i]
	i += 1
	count += 1
count += -(-max(0, H - damege) // A)
print(count)


(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(q, w) = map(int, input().split())
	a += [q]
	b += [w]
m = max(a)
b = [i for i in b if i >= m]
b.sort(reverse=True)
x = 0
for i in b:
	h -= i
	x += 1
	if h <= 0:
		break
if h > 0:
	x += -(-h // m)
print(x)


(N, H) = map(int, input().split())
w = []
for i in range(N):
	(a, b) = map(int, input().split())
	w.append((a, 0))
	w.append((b, 1))
w.sort(reverse=True)
ans = 0
for (v, t) in w:
	if t == 1:
		H -= v
		ans += 1
	else:
		ans += -(-H // v)
		H = 0
	if H <= 0:
		break
print(ans)


(n, h) = map(int, input().split())
A = []
B = []
w = 0
sub = 0
for i in range(n):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
	w = max(a, w)
ans = 0
B.sort(reverse=True)
for i in range(n):
	if B[i] > w:
		h -= B[i]
		ans += 1
		if 1 > h:
			print(ans)
			exit()
ans += h // w
if h % w == 0:
	print(ans)
else:
	print(ans + 1)


(n, h) = map(int, input().split())
(a, b) = ([], [])
for _ in range(n):
	(A, B) = map(int, input().split())
	a += [A]
	b += [B]
c = max(a)
b.sort()
ans = 0
for i in b[::-1]:
	if i > c and h > 0:
		h -= i
		ans += 1
	else:
		break
print(ans - -h // c * (h > 0))


(n, h) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
A = []
B = []
for (a, b) in AB:
	A.append(a)
	B.append(b)
max_A = max(A)
C = sorted([b for b in B if b >= max_A], reverse=True)
cnt = 0
for c in C:
	h -= c
	cnt += 1
	if h <= 0:
		print(cnt)
		return
atack = h // max_A
cnt += atack
h -= atack * max_A
if h <= 0:
	print(cnt)
else:
	print(cnt + 1)


def LI():
	return list(map(int, input().split()))
(N, H) = LI()
amax = 0
blist = []
for _ in range(N):
	(a, b) = LI()
	amax = max(amax, a)
	blist.append(b)
blist.sort()
ans = 0
for i in range(N - 1, -1, -1):
	if blist[i] <= amax:
		break
	ans += 1
	H -= blist[i]
	if H <= 0:
		break
if H > 0:
	if H % amax == 0:
		ans += H // amax
	else:
		ans += H // amax + 1
print(ans)


import math
(n, h) = map(int, input().split())
m = 0
b = []
for _ in range(n):
	(A, B) = map(int, input().split())
	if A > m:
		m = A
	b.append(B)
b.sort()
j = n - 1
ans = 0
while True:
	if j < 0 or b[j] <= m:
		ans += math.ceil(h / m)
		break
	h -= b[j]
	j -= 1
	ans += 1
	if h <= 0:
		break
print(ans)


import math
(N, H) = map(int, input().split())
src = [tuple(map(int, input().split())) for i in range(N)]
n = max(src)[0]
src.sort(key=lambda x: x[1], reverse=True)
ans = d = 0
for (a, b) in src:
	if b <= n:
		break
	d += b
	ans += 1
	if d >= H:
		print(ans)
		exit()
ans += math.ceil((H - d) / n)
print(ans)


(N, H) = map(int, input().split())
S = [[int(x) for x in input().split()] for _ in range(N)]
(A, B) = zip(*S)
A = max(A)
B = [b for b in B if b > A]
B.sort(reverse=True)
ans = 0
cnt = 0
for b in B:
	if H <= 0:
		break
	cnt += 1
	H -= b
if H > 0:
	cnt += (H - 1) // A + 1
print(cnt)


(n, h) = map(int, input().split())
al = []
bl = []
for _ in [0] * n:
	(a, b) = map(int, input().split())
	al.append(a)
	bl.append(b)
al.sort()
bl.sort()
ans = 0
while h > 0:
	if len(bl) > 0 and bl[-1] > al[-1]:
		h -= bl[-1]
		ans += 1
		del bl[-1]
	else:
		ans += -(-h // al[-1])
		h = 0
print(ans)


from math import ceil
(n, h) = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
(a, b) = [list(i) for i in zip(*k)]
b.sort(reverse=True)
a = max(a)
ans = 0
for i in b:
	if i > a:
		ans += 1
		h -= i
		if h <= 0:
			print(ans)
			return
	else:
		break
print(ans + ceil(h / a))


(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)
A = sorted(A)[::-1]
B = sorted(B)[::-1]
ret = 0
if B[0] < A[0]:
	if H % A[0] == 0:
		ret = H // A[0]
	else:
		ret = H // A[0] + 1
	H = 0
else:
	for b in B:
		if b < A[0]:
			if H % A[0] == 0:
				ret += H // A[0]
			else:
				ret += H // A[0] + 1
			H = 0
			break
		else:
			ret += 1
			H -= b
		if H <= 0:
			break
	if H > 0:
		if H % A[0] == 0:
			ret += H // A[0]
		else:
			ret += H // A[0] + 1
print(ret)


(N, H, *blades) = map(int, open(0).read().split())
cut = max(blades[::2])
throws = sorted((b for b in blades[1::2] if b >= cut))
ans = 0
while throws:
	H -= throws.pop()
	ans += 1
	if H <= 0:
		print(ans)
		exit()
ans += (H + cut - 1) // cut
print(ans)


(n, h) = map(int, input().split())
AB = list((tuple(map(int, input().split())) for i in range(n)))
(A, B) = zip(*AB)
a = max(A)
count = 0
for i in sorted(B)[::-1]:
	if i >= a:
		h -= i
		count += 1
	if h <= 0:
		print(count)
		exit()
print(count + h // a if h % a == 0 else 1 + count + h // a)


import math
(n, h) = map(int, input().split())
ab = [None] * n
for i in range(n):
	ab[i] = tuple(map(int, input().split()))
amax = max([m[0] for m in ab])
ans = 0
for (a, b) in sorted(ab, key=lambda m: -m[1]):
	if b <= amax:
		break
	h -= b
	ans += 1
	if h <= 0:
		print(ans)
		return
ans += math.ceil(h / amax)
print(ans)


(N, H) = map(int, input().split())
c = [list(map(int, input().split())) for _ in [0] * N]
a = max((r[0] for r in c))
b = sorted((r[1] for r in c if r[1] > a))
n = 0
while H > 0 and b:
	H -= b.pop()
	n += 1
print(n + max(H - 1, -1) // a + 1)


(N, H) = list(map(int, input().split()))
A = 0
B = []
for i in range(N):
	(a, b) = list(map(int, input().split()))
	A = max(A, a)
	B.append(b)
B = sorted(B, reverse=True) + [0]
i = 0
while B[i] >= A:
	i += 1
B = B[:i]
ans = 0
for i in range(len(B)):
	H -= B[i]
	ans += 1
	if H <= 0:
		print(ans)
		return
print(ans + (H - 1) // A + 1)


(N, H) = map(int, input().split())
B = []
a_max = 0
for i in range(N):
	(a, b) = map(int, input().split())
	a_max = max(a_max, a)
	B.append(b)
B = sorted([b for b in B if b > a_max], reverse=True)
cnt = 0
for b in B:
	H -= b
	cnt += 1
	if H <= 0:
		break
if H > 0:
	cnt += (H - 1) // a_max + 1
print(cnt)


(n, h) = list(map(int, input().split()))
cut = 0
throw = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	cut = max(cut, a)
	throw.append(b)
throw.sort(reverse=True)
throw_cam = []
for i in range(n):
	if cut > throw[i]:
		break
	if i == 0:
		throw_cam.append(throw[0])
	else:
		throw_cam.append(throw[i] + throw_cam[i - 1])
if throw_cam[len(throw_cam) - 1] < h:
	rh = h - throw_cam[len(throw_cam) - 1]
	if rh % cut == 0:
		print(len(throw_cam) + rh // cut)
	else:
		print(len(throw_cam) + rh // cut + 1)
else:
	for i in range(len(throw_cam)):
		d = throw_cam[i]
		if d >= h:
			print(i + 1)
			break


from math import ceil
(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()
B.sort()
ans = 0
for i in B[::-1]:
	if i < A[-1]:
		break
	H -= i
	ans += 1
	if H <= 0:
		print(ans)
		quit()
ans += ceil(H / A[-1])
print(ans)


from math import ceil
(N, H) = map(int, input().split())
(a, b) = ([0] * N, [0] * N)
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
a = max(a)
b.sort(reverse=True)
ans = 0
atk = 0
for i in range(N):
	if a >= b[i] or atk >= H:
		break
	ans += 1
	atk += b[i]
if atk < H:
	ans += ceil((H - atk) / a)
print(ans)


import math
(n, h) = map(int, input().split())
(a, b) = (0, [])
for i in range(n):
	(k, l) = map(int, input().split())
	a = max(a, k)
	b.append(l)
b.sort(reverse=True)
cnt = 0
idx = 0
while h > 0:
	if idx < len(b) and b[idx] > a:
		h -= b[idx]
		idx += 1
		cnt += 1
	else:
		cnt += math.ceil(h / a)
		h = 0
print(cnt)


(n, h) = map(int, input().split())
a = []
b = []
for _ in range(n):
	(tmp_a, tmp_b) = map(int, input().split())
	a.append(tmp_a)
	b.append(tmp_b)
v = max(a)
b.sort(reverse=True)
i = 0
while i < n and b[i] > v and (h > 0):
	h -= b[i]
	i += 1
if h <= 0:
	print(i)
else:
	print(i + (h + v - 1) // v)


(n, h) = list(map(int, input().split()))
num = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	num.append([a, 0])
	num.append([b, 1])
num.sort(reverse=True, key=lambda x: x[0])
ans = 0
for i in range(n * 2):
	if num[i][1] == 1:
		ans += 1
		h -= num[i][0]
		if h <= 0:
			break
	else:
		ans += -(h // -num[i][0])
		break
print(ans)


(n, h) = map(int, input().split())
abl = [list(map(int, input().split())) for nesya in range(n)]
abl.sort()
amax = abl[-1][0]
b_list = []
for ab in abl:
	b = ab[1]
	if amax <= b:
		b_list.append(b)
b_list.sort()
ans = 0
for num in b_list[::-1]:
	h -= num
	ans += 1
	if h <= 0:
		print(ans)
		return
if h % amax == 0:
	print(ans + h // amax)
else:
	print(ans + h // amax + 1)


import math
(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(a1, b1) = map(int, input().split())
	a.append(a1)
	b.append(b1)
b.sort()
max_a = max(a)
ans = 0
for i in b[::-1]:
	if i > max_a:
		h -= i
		ans += 1
	else:
		break
	if h <= 0:
		print(ans)
		exit()
ans += math.ceil(h / max_a)
print(ans)


from math import ceil
(N, H) = map(int, input().split())
(A, B) = (0, [])
for i in range(N):
	(a, b) = map(int, input().split())
	A = max(A, a)
	B.append(b)
B = [b for b in B if b > A]
B.sort()
ans = 0
while H > 0 and B:
	ans += 1
	H -= B.pop()
H = max(0, H)
ans += ceil(H / A)
print(ans)


(n, h) = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1], reverse=True)
m = max([i[0] for i in ab])
ans = 0
for i in ab:
	if i[1] > m:
		h -= i[1]
		ans += 1
		if h <= 0:
			print(ans)
			exit()
if h % m == 0:
	print(ans + h // m)
else:
	print(ans + h // m + 1)


(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
ab = sorted(a + b)[::-1]
ans = 0
for i in ab[:ab.index(max(a))]:
	h -= i
	ans += 1
	if h <= 0:
		print(ans)
		exit()
ans += (h + max(a) - 1) // max(a)
print(ans)


import math
(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)
ans = 0
B.sort(reverse=True)
Am = max(A)
for i in range(N):
	if B[i] >= Am:
		H -= B[i]
		ans += 1
	if H <= 0:
		break
if H > 0:
	ans += math.ceil(H / Am)
print(ans)


(N, H) = map(int, input().split())
(A, B) = ([0 for _ in range(N)], [0 for _ in range(N)])
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
m = max(A)
B.sort(reverse=True)
cnt = N - 1
while B[cnt] < m:
	cnt -= 1
ccnt = 0
for i in range(cnt + 1):
	H -= B[i]
	ccnt += 1
	if H <= 0:
		break
if H > 0:
	ccnt += -(-H // m)
print(ccnt)


(n, h) = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
(A, B) = zip(*AB)
a = max(A)
B = [b for b in B if b > a]
B.sort(reverse=True)
ans = 0
hp = h
attack_cnt = 0
for b in B:
	if hp <= 0:
		break
	attack_cnt += 1
	hp -= b
if hp > 0:
	attack_cnt += (hp - 1) // a + 1
print(attack_cnt)


(N, H) = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1], reverse=True)
a_max = 0
for i in range(N):
	a_max = max(a_max, AB[i][0])
cnt = 0
sum_throw = 0
for i in range(N):
	if AB[i][1] > a_max:
		sum_throw += AB[i][1]
		cnt += 1
		if sum_throw >= H:
			print(cnt)
			return
rem = H - sum_throw
(q, r) = divmod(rem, a_max)
if r == 0:
	cnt += q
else:
	cnt += q + 1
print(cnt)


(n, h) = map(int, input().split())
A = list((tuple(map(int, input().split())) for i in range(n)))
(A, B) = zip(*A)
a = max(A)
count = 0
for i in sorted(B)[::-1]:
	if h <= 0:
		break
	elif i >= a:
		count += 1
		h -= i
if h > 0:
	count += (h - 1) // a + 1
print(count)


(N, H) = map(int, input().split())
a = 0
b = []
for _ in range(N):
	(A, B) = map(int, input().split())
	a = max(a, A)
	b.append(B)
b = sorted(b, reverse=True)
ans = 0
for i in range(N):
	if b[i] <= a:
		break
	H -= b[i]
	ans += 1
	if H <= 0:
		print(ans)
		exit()
print(ans - -H // a)


from bisect import bisect
(N, H) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
(A, B) = zip(*AB)
B = sorted(B)
max_A = max(A)
knifes = B[bisect(B, max_A):]
count = 0
while H > 0 and knifes:
	H -= knifes.pop()
	count += 1
if H > 0:
	count += -(-H // max_A)
print(count)


(n, h) = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
a = max([l[0] for l in ls])
bs = [l[1] for l in ls if l[1] > a]
bs.sort()
res = 0
while h > 0 and len(bs) > 0:
	h -= bs.pop()
	res += 1
if h > 0:
	res += (h + a - 1) // a
print(res)


import sys
from collections import deque, defaultdict, namedtuple
import heapq
from math import sqrt, factorial, gcd, ceil, atan, pi

def input():
	return sys.stdin.readline()[:-1]
import string
import operator
import random
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
MOD = int(1000000000.0) + 7
INF = float('inf')

def solve():
	(n, H) = [int(x) for x in input().split()]
	a = [0] * n
	b = [0] * n
	for i in range(n):
		(a[i], b[i]) = [int(x) for x in input().split()]
	mx = max(a)
	b.sort(reverse=True)
	ans = (H + mx - 1) // mx
	pref = 0
	for i in range(n):
		pref += b[i]
		cur = i + 1 + (max(0, H - pref) + mx - 1) // mx
		ans = min(ans, cur)
	print(ans)
T = 1
for case in range(1, T + 1):
	ans = solve()


import sys
input = sys.stdin.readline
(N, H) = map(int, input().split())
katanas = []
for _ in range(N):
	(a, b) = map(int, input().split())
	katanas.append((a, b))
max_a = sorted(katanas, reverse=True)[0][0]
throws = []
for (a, b) in katanas:
	if max_a < b:
		throws.append(b)
ans = 0
for b in sorted(throws, reverse=True):
	H -= b
	ans += 1
	if H <= 0:
		print(ans)
		return
print(ans + (H - 1) // max_a + 1)


(n, h) = list(map(int, input().split()))
wield = 0
bs = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a > wield:
		wield = a
	bs.append(b)
throw = []
for i in range(n):
	if bs[i] > wield:
		throw.append(bs[i])
total = sum(throw)
if total > h:
	throw = sorted(throw, reverse=True)
	total = 0
	ind = 0
	while total < h:
		total += throw[ind]
		ind += 1
	print(ind)
else:
	print((h - total + wield - 1) // wield + len(throw))


f = lambda : map(int, input().split())
(n, h) = f()
(mA, B) = (0, [])
for _ in range(n):
	(a, b) = f()
	mA = max(mA, a)
	B.append(b)
B = sorted([i for i in B if i > mA], reverse=True)
ans = 0
while h > 0:
	if not B:
		ans += -(-h // mA)
		break
	else:
		h -= B[0]
		B.pop(0)
		ans += 1
print(ans)


def resolve():
	(N, H) = [int(item) for item in input().split()]
	ab = [[int(item) for item in input().split()] for _ in range(N)]
	ab.sort(reverse=True, key=lambda x: x[1])
	a_max_ab = max(ab, key=lambda x: x[0])
	cnt = 0
	for (a, b) in ab:
		if b > a_max_ab[0]:
			H -= b
			cnt += 1
		if H <= 0:
			break
	if H > 0:
		cnt += H // a_max_ab[0]
		if H % a_max_ab[0] != 0:
			cnt += 1
	print(cnt)

def __starting_point():
	resolve()
__starting_point()


(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)
A_sorted = sorted(A, reverse=True)
B_sorted = sorted(B, reverse=True)
ans = 0
attack_sum = 0
for i in range(N):
	if B_sorted[i] >= A_sorted[0]:
		if H > attack_sum:
			attack_sum += B_sorted[i]
			ans += 1
		else:
			print(ans)
			return
	else:
		break
ans += -(-(H - attack_sum) // A_sorted[0])
print(ans)


import math
import sys

def input():
	return sys.stdin.readline()[:-1]
(N, H) = list(map(int, input().split()))
max_a = 0
max_a_b = 0
AB = []
for _ in range(N):
	ab = list(map(int, input().split()))
	AB.append(ab)
	if max_a < ab[0]:
		max_a = ab[0]
		max_a_b = ab[1]
	elif max_a == ab[0] and max_a_b > ab[1]:
		max_a = ab[0]
		max_a_b = ab[1]
AB.sort(key=lambda x: x[1], reverse=True)
throw_sum = 0
ans = 0
for i in range(N):
	if max_a < AB[i][1]:
		throw_sum += AB[i][1]
		ans += 1
		if throw_sum >= H:
			print(ans)
			return
H -= throw_sum
ans += math.ceil(H / max_a)
print(ans)


import math
(N, H) = list(map(int, input().split()))
swing = []
throw = []
for _ in range(N):
	(sw, th) = list(map(int, input().split()))
	swing.append(sw)
	throw.append(th)
swing.sort(reverse=True)
throw.sort(reverse=True)
if swing[0] >= throw[0]:
	print(math.ceil(H / swing[0]))
else:
	cnt = 0
	damage_sum = 0
	while cnt < len(throw):
		if throw[cnt] <= swing[0]:
			break
		damage_sum += throw[cnt]
		cnt += 1
		if damage_sum >= H:
			print(cnt)
			return
	print(math.ceil(cnt + (H - damage_sum) / swing[0]))


(N, H) = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
	(a, b) = map(int, input().split())
	slash = max(slash, a)
	if b > a:
		Throw.append(b)
import heapq as hq
Throw = [-th for th in Throw if th > slash]
hq.heapify(Throw)
(dmg, cnt) = (0, 0)
while len(Throw) != 0:
	if dmg >= H:
		break
	dmg += -hq.heappop(Throw)
	cnt += 1
if dmg < H:
	from math import ceil
	cnt += ceil((H - dmg) / slash)
print(cnt)


from heapq import heappop, heappush
(N, H) = map(int, input().split())
a = [None] * N
b = [None] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
a.sort()
b.sort()
q = []
for i in range(N):
	if b[i] > a[-1]:
		heappush(q, -b[i])
ans = 0
while q:
	H += heappop(q)
	ans += 1
	if H <= 0:
		print(ans)
		return
print(ans + (H + a[-1] - 1) // a[-1])


import sys
import math
(n, h) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
a = [ab[i][0] for i in range(n)]
A = max(a)
b = [ab[i][1] for i in range(n) if ab[i][1] > A]
b = sorted(b, reverse=True)
cnt = 0
for i in b:
	h -= i
	cnt += 1
	if h <= 0:
		print(cnt)
		sys.exit()
print(cnt + math.ceil(h / A))


(n, h) = map(int, input().split())
an = [0] * n
bn = [0] * n
for i in range(n):
	(an[i], bn[i]) = map(int, input().split())
an.sort(reverse=True)
bn.sort(reverse=True)
ans = 0
for b in bn:
	if b > an[0] and h > 0:
		h -= b
		ans += 1
ans += 0 if h <= 0 else h // an[0] + (1 if h % an[0] > 0 else 0)
print(ans)


import math
(N, H) = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
B = sorted(B, reverse=True)
maxa = max(A)
ans = 0
for b in B:
	if b < maxa:
		break
	ans += 1
	H -= b
	if H <= 0:
		break
H = max(0, H)
ans += math.ceil(H / maxa)
print(ans)


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

def solver(N, H, A, B):
	x = max(A)
	B.sort()
	B.reverse()
	ans = 0
	for b in B:
		if b < x:
			break
		H -= b
		ans += 1
		if H <= 0:
			return ans
	return ans + -(-H // x)
print(solver(N, H, A, B))


from bisect import bisect_left, bisect
import sys
(n, h) = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = list(map(int, input().split()))
amax = max(a)
b.sort()
ii = bisect(b, amax)
b = b[ii:]
b.reverse()
icnt = 0
for bi in b:
	icnt += 1
	h = h - bi
	if h <= 0:
		print(icnt)
		return
di = (h - 1) // amax + 1
print(icnt + di)


(n, h) = map(int, input().split())
x = [0] * n
y = 0
for i in range(n):
	(a, b) = map(int, input().split())
	y = max(y, a)
	x[i] = b
cnt = 0
x.sort(reverse=1)
for i in x:
	if i > y:
		cnt += 1
		h -= i
	if h <= 0:
		print(cnt)
		exit()
print(cnt + (h + y - 1) // y)


(n, h, *L) = map(int, open((x := 0)).read().split())
a = max(L[::2])
B = sorted([l for l in L[1::2] if l > a])
for b in B[::-1]:
	h -= b
	x += 1
	if h < 1:
		break
print(x - min(0, -h // a))


(N, H) = list(map(int, input().split()))
B = []
A = 0
for _ in range(N):
	(a, b) = list(map(int, input().split()))
	A = max(A, a)
	B.append(b)
B.sort(reverse=True)
ans = (H - 1) // A + 1
for i in range(N):
	H -= B[i]
	if H <= 0:
		ans = min(ans, i + 1)
		break
	ans = min(ans, (H - 1) // A + 1 + i + 1)
print(ans)


(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
max_a = max(a)
ans = 0
for x in reversed(sorted(filter(lambda x: x >= max_a, b))):
	h -= x
	ans += 1
	if h <= 0:
		break
ans += max(0, (h + max_a - 1) // max_a)
print(ans)


f = lambda : [*map(int, input().split())]
(n, h) = f()
(A, B) = ([], [])
for _ in range(n):
	(a, b) = f()
	A += [a]
	B += [b]
m = max(A)
B.sort()
c = 0
for b in sorted(B)[::-1]:
	if b > m:
		h -= b
		c += 1
		if h < 1:
			break
print(c - -h // m * (h > 0))


(n, h) = map(int, input().split())
alst = []
blst = []
for _ in range(n):
	(a, b) = map(int, input().split())
	alst.append(a)
	blst.append(b)
blst.sort(reverse=True)
a = max(alst)
ans = 0
for num in blst:
	if num < a:
		ans += (h - 1) // a + 1
		break
	else:
		ans += 1
		h -= num
		if h <= 0:
			break
else:
	ans += (h - 1) // a + 1
print(ans)


(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
a.sort()
b.sort()
chk = max(a)
ans = 0
for i in b[::-1]:
	if h <= 0 or i < chk:
		break
	ans += 1
	h -= i
if h > 0:
	ans += (h + chk - 1) // chk
print(ans)


(N, H) = map(int, input().split())
ls = []
for i in range(N):
	(a, b) = map(int, input().split())
	ls.append([a, b])
ls.sort()
ls.sort(key=lambda x: -x[0])
mainkatana = ls.pop(0)
ls.sort(key=lambda x: -x[1])
ls.append([0, 0])
ii = 0
while ls[0][1] >= mainkatana[0] and H > mainkatana[1]:
	ii += 1
	nage = ls.pop(0)
	H -= nage[1]
cut = max(0, -(-(H - mainkatana[1]) // mainkatana[0]))
ii += cut
if H > 0:
	ii += 1
print(ii)


import math
(N, H) = map(int, input().split())
ab = [[int(x) for x in input().split()] for _ in range(N)]
(a, _) = max(ab)
B = sorted([b for (_, b) in ab if b > a], reverse=True)
sb = sum(B)
if sb < H:
	print(len(B) + math.ceil((H - sb) / a))
else:
	B.insert(0, 0)
	for i in range(1, len(B)):
		B[i] += B[i - 1]
		if B[i] >= H:
			break
	print(i)


(N, H) = map(int, input().split())
(A, B) = ([0] * N, [0] * N)
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
amax = max(A)
newb = sorted((b for b in B if b > amax))
cnt = 0
while H > 0 and newb:
	cnt += 1
	H -= newb.pop()
if H > 0:
	cnt += (H + amax - 1) // amax
print(cnt)


from heapq import *
(n, h) = map(int, input().split())
k = []
for _ in [0] * n:
	(a, b) = map(int, input().split())
	heappush(k, (-a, 1))
	heappush(k, (-b, 0))
ans = 0
while h > 0:
	(a, i) = heappop(k)
	a = -a
	if i:
		ans += (h + a - 1) // a
		break
	else:
		ans += 1
		h -= a
print(ans)


(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)
amax = max(A)
ans = 0
l = 0
for b in B:
	if l >= H:
		print(ans)
		exit()
	if b > amax:
		ans += 1
		l += b
	else:
		break
ans += (H - l) // amax + min((H - l) % amax, 1)
print(ans)


import heapq as hq
from math import ceil
(N, H) = map(int, input().split())
A = 0
B = []
for i in range(N):
	(a, b) = map(int, input().split())
	A = max(A, a)
	hq.heappush(B, -b)
ans = 0
while H > 0 and B:
	b = -hq.heappop(B)
	if b > A:
		H -= b
		ans += 1
	else:
		break
if H > 0:
	ans += ceil(H / A)
print(ans)


import math
(n, h) = map(int, input().split())
a_l = []
b_l = []
c = 0
for i in range(n):
	(a, b) = map(int, input().split())
	a_l.append(a)
	b_l.append(b)
a_l.sort()
b_l.sort()
for i in range(1, n + 1):
	if a_l[-1] <= b_l[-1 * i]:
		h -= b_l[-1 * i]
		c += 1
		if h <= 0:
			break
	else:
		break
if h > 0:
	c += math.ceil(h / a_l[-1])
print(c)


from bisect import bisect_right
(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(a1, b1) = map(int, input().split())
	a.append(a1)
	b.append(b1)
a_s = sorted(a, reverse=1)
b_s1 = sorted(b)
b_s = sorted(list(b_s1[bisect_right(b_s1, a_s[0]):]), reverse=1)
count = 0
sum = 0
for j in b_s:
	sum += j
	count += 1
	if h <= sum:
		print(count)
		break
else:
	if (h - sum) % a_s[0] == 0:
		print(count + (h - sum) // a_s[0])
	else:
		print(count + 1 + (h - sum) // a_s[0])


import sys
(N, H) = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
	(a, b) = map(int, input().split())
	(A[i], B[i]) = (a, b)
max_A = max(A)
B.sort(reverse=True)
K = 0
for b in B:
	if H > 0 and b >= max_A:
		K += 1
		H -= b
if H > 0:
	K += (H + max_A - 1) // max_A
print(K)


(n, h) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	(c, d) = map(int, input().split())
	a.append(c)
	b.append(d)
a_max = max(a)
b = sorted(b, reverse=True)
piv = 0
res = 0
while h > 0 and piv < n and (b[piv] > a_max):
	res += 1
	h -= b[piv]
	piv += 1
if h > 0:
	res += (h + a_max - 1) // a_max
print(res)


(N, H) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort()
M = ab[-1][0]
B = [b for (a, b) in ab]
B.sort()
B = B[::-1]
ans = 0
for b in B:
	if H > 0 and b > M:
		H -= b
		ans += 1
	else:
		break
ans += 0 - -max(0, H) // M
print(ans)


(n, h) = map(int, input().split())
list_AB = [list(map(int, input().split(' '))) for _ in range(n)]
cnt = 0
A = 0
for (a, b) in list_AB:
	A = max(A, a)
list_AB.sort(key=lambda x: x[1], reverse=True)
for (a, b) in list_AB:
	if b > A:
		h -= b
		cnt += 1
	if h <= 0:
		break
if h > 0:
	if h % A == 0:
		cnt += h // A
	else:
		cnt += h // A + 1
print(cnt)


3
(N, H) = (int(x) for x in input().split())
A = []
B = []
for i in range(N):
	(a, b) = (int(x) for x in input().split())
	A.append(a)
	B.append(b)
A.sort(reverse=True)
B.sort(reverse=True)
ret = 0
AMax = A[0]
for b in B:
	if b < AMax or H <= 0:
		break
	H -= b
	ret += 1
if H > 0:
	ret += H // AMax
	if H % AMax != 0:
		ret += 1
print(ret)


(N, H) = map(int, input().split())
a_max = 0
b_list = []
count = 0
for _ in range(N):
	(a, b) = map(int, input().split())
	a_max = max(a, a_max)
	b_list.append(b)
b_list.sort(reverse=True)
for b in b_list:
	if b > a_max:
		H -= b
		count += 1
	else:
		break
	if H <= 0:
		print(count)
		exit()
print((H - 1) // a_max + 1 + count)


(N, H) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
B = []
C = []
for (a, b) in A:
	B.append(a)
	C.append(b)
D = sorted(B)[::-1]
b = D[0]
F = []
for i in C:
	if b < i:
		F.append(i)
G = sorted(F)[::-1]
cnt = 0
for i in G:
	H -= i
	cnt += 1
	if H <= 0:
		print(cnt)
		exit()
print(cnt - -H // b)


import math
(n, h) = map(int, input().split())
(a, b) = ([0] * n, [0] * n)
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
amax = max(a)
cnt = 0
for bi in sorted(b, reverse=True):
	if bi < amax:
		break
	cnt += 1
	h -= bi
	if h <= 0:
		break
if h > 0:
	cnt += math.ceil(h / amax)
print(cnt)


import math
(n, h) = map(int, input().split())
(a, b) = zip(*(map(int, input().split()) for _ in range(n)))
m = max(a)
r = 0
for i in sorted(b)[::-1]:
	if h <= 0 or i <= m:
		break
	h -= i
	r += 1
print(r + math.ceil(max(h, 0) / m))


(n, h) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
(A, B) = zip(*l)
max_a = max(A)
c = 0
for b in sorted([b for b in B if b > max_a], reverse=True):
	h -= b
	c += 1
	if h <= 0:
		print(c)
		exit()
print(c + h // max_a + (h % max_a != 0))


import bisect
import math
(N, H) = list(map(int, input().split()))
swing = []
throw = []
for _ in range(N):
	(sw, th) = list(map(int, input().split()))
	swing.append(sw)
	throw.append(th)
swing.sort(reverse=True)
throw.sort()
idx = bisect.bisect_right(throw, swing[0])
if idx == len(throw):
	print(math.ceil(H / swing[0]))
else:
	throw = throw[idx:]
	cnt = 0
	damage_sum = 0
	for i in reversed(throw):
		cnt += 1
		damage_sum += i
		if damage_sum >= H:
			print(cnt)
			return
	print(math.ceil(cnt + (H - damage_sum) / swing[0]))


import math
(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)
B.sort(reverse=True)
nage = 0
ans = math.ceil((H + maxA) / maxA)
for i in range(N):
	nage += B[i]
	ans = min(ans, i + 1 + math.ceil(max(0, H - nage) / maxA))
print(ans)


(N, H) = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
a = max([i[0] for i in AB])
B = sorted([i[1] for i in AB if i[1] > a], reverse=True)
count = 0
for b in B:
	H -= b
	count += 1
	if H <= 0:
		break
if H > 0:
	count += H // a + 1 * (H % a > 0)
print(count)


(n, h, *k) = map(int, open(0).read().split())
a = 0
b = []
for (i, j) in zip(*[iter(k)] * 2):
	a = max(a, i)
	b.append(j)
b = sorted(b, reverse=True)
ans = 0
while ans < n and b[ans] > a and (h > 0):
	h -= b[ans]
	ans += 1
if h > 0:
	ans += (h + a - 1) // a
print(ans)


def i2():
	return [int(i) for i in input().split()]
[n, h] = i2()
a = []
for i in range(n):
	b = i2()
	a += [[b[0], 0], [b[1], 1]]
a.sort()
a = a[::-1]
i = 0
c = 0
while a[i][1] == 1 and h > 0:
	h -= a[i][0]
	c += 1
	i += 1
if h > 0:
	c += h // a[i][0]
	if h % a[i][0]:
		c += 1
print(c)


from math import ceil
(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)
ma = max(a)
mb = [i for i in b if i > ma]
mb.sort(reverse=True)
if sum(mb) >= h:
	i = 0
	while h > 0:
		h -= mb[i]
		i += 1
	print(i)
else:
	cnt = len(mb)
	h -= sum(mb)
	print(cnt + ceil(h / ma))


(n, h) = map(int, input().split())
amax = 0
bs = []
for i in range(n):
	(a, b) = map(int, input().split())
	amax = max(amax, a)
	bs.append(b)
bs = sorted([i for i in bs if i >= amax], reverse=True)
ans = 0
for i in bs:
	h -= i
	ans += 1
	if h <= 0:
		break
else:
	ans += (h + amax - 1) // amax
print(ans)


(N, H) = map(int, input().split())
(A, B) = ([0] * N, [0] * N)
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
target = max(A)
ans = 0
B.sort(reverse=True)
for i in B:
	if i >= target:
		H -= i
		ans += 1
	if H <= 0:
		print(ans)
		exit()
print(ans - -H // target)


(N, M) = map(int, input().split())
(X, Y) = ([], [])
for _ in range(N):
	(x, y) = map(int, input().split())
	X.append(x)
	Y.append(y)
mx = max(X)
Y.sort()
r = 0
for y in Y[::-1]:
	if y < mx:
		break
	r += 1
	M -= y
	if M <= 0:
		break
if M > 0:
	r += -(-M // mx)
print(r)


(N, H) = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
a_max = max(a)
ans = dmg = 0
for dmg_i in sorted([bi for bi in b if bi > a_max], reverse=True):
	dmg += dmg_i
	ans += 1
	if dmg >= H:
		print(ans)
		break
else:
	print(ans + (H - dmg + a_max - 1) // a_max)


from bisect import bisect_left
(N, H) = map(int, input().split())
amax = 0
B = []
for i in range(N):
	(a, b) = map(int, input().split())
	if a > amax:
		amax = a
	B.append(b)
B = sorted(B)
idx = bisect_left(B, amax)
B = B[idx:][::-1]
cum = [0]
for i in range(len(B)):
	cum += [cum[-1] + B[i]]
	if cum[-1] >= H:
		print(i + 1)
		return
print(len(B) + (H - cum[-1] + amax - 1) // amax)


import math
(N, H) = map(int, input().split())
A = []
r = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append([a, 0])
	A.append([b, 1])
A.sort()
ans = 0
while H > 0:
	p = A.pop()
	if p[1] == 1:
		H -= p[0]
		ans += 1
	else:
		ans += math.ceil(H / p[0])
		break
print(ans)


(n, h) = map(int, input().split())
a = []
b = []
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
b.sort(reverse=True)
c = max(a)
for i in b:
	if i > c:
		h -= i
		ans += 1
		if h <= 0:
			print(ans)
			exit()
ans += (h + c - 1) // c
print(ans)


(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)
count = 0
for b in B:
	if b > A[0]:
		H -= b
		count += 1
	else:
		break
	if H <= 0:
		break
if H > 0:
	count += (H + A[0] - 1) // A[0]
print(count)


(n, h) = map(int, input().split())
(A, B) = ([0] * n, [0] * n)
for i in range(n):
	(A[i], B[i]) = map(int, input().split())
maxa = max(A)
(c, d) = (0, 0)
for i in sorted(B)[::-1]:
	if i > maxa:
		c += i
		d += 1
		if c >= h:
			print(d)
			exit()
ans = d - (c - h) // maxa
print(ans)


((n, h), *ab) = [list(map(int, s.split())) for s in open(0)]
mxa = max([a for (a, b) in ab])
bb = sorted([b for (a, b) in ab if b > mxa], reverse=True)
ans = 0
for b in bb:
	h -= b
	ans += 1
	if h <= 0:
		break
if h > 0:
	ans += 0 - -h // mxa
print(ans)


(N, H) = map(int, input().split())
src = [tuple(map(int, input().split())) for i in range(N)]
maxa = 0
bs = []
for (a, b) in src:
	maxa = max(maxa, a)
	bs.append(b)
bs.sort()
ans = 0
while bs:
	b = bs.pop()
	if b <= maxa:
		break
	H -= b
	ans += 1
	if H <= 0:
		print(ans)
		exit()
ans += -(-H // maxa)
print(ans)


import math
(n, h) = map(int, input().split())
katana = []
a_max = 0
for i in range(n):
	ab = list(map(int, input().split()))
	katana.append(ab)
	a_max = max(a_max, ab[0])
katana = sorted(katana, key=lambda x: x[1], reverse=True)
life = h
count = 0
for (a, b) in katana:
	if b <= a_max:
		break
	else:
		life -= b
	count += 1
	if life <= 0:
		break
if life > 0:
	count += math.ceil(life / a_max)
print(count)


from math import ceil
(N, H) = map(int, input().split())
B = []
a = 0
for i in range(N):
	(aa, b) = map(int, input().split())
	if a < aa:
		a = aa
	B.append(b)
B.sort(reverse=True)
res = 0
for b in B:
	if a < b:
		H -= b
	else:
		break
	res += 1
	if H <= 0:
		break
if H <= 0:
	print(res)
else:
	print(res + ceil(H / a))


from math import ceil
(n, h) = map(int, input().split())
a = []
b = []
for i in range(n):
	(p, q) = map(int, input().split())
	a.append(p)
	b.append(q)
b.sort(reverse=1)
ans = 0
m = max(a)
for i in b:
	if i < m or h <= 0:
		break
	h -= i
	ans += 1
if h > 0:
	ans += ceil(h / m)
print(ans)


(n, h) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	inp = list(map(int, input().split()))
	a.append(inp[0])
	b.append(inp[1])
am = max(a)
b.sort()
b.reverse()
c = 0
for i in b:
	if i < am:
		break
	c += 1
	h -= i
	if h <= 0:
		break
c += max((h - 1) // am + 1, 0)
print(c)


import sys
(n, h) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
l.sort()
x = l[-1][0]
L = []
for i in range(n):
	if l[i][1] > x:
		L.append(l[i][1])
L.sort()
L.reverse()
ct = 0
for i in range(len(L)):
	h -= L[i]
	ct += 1
	if h <= 0:
		print(ct)
		sys.exit()
print(ct + (h + x - 1) // x)


(N, H) = map(int, input().split())
K = [list(map(int, input().split())) for n in range(N)]
A = max((k[0] for k in K))
B = sorted((b for (a, b) in K if A < b))
C = 0
while 0 < H and B:
	H -= B.pop()
	C += 1
print(C - -max(0, H) // A)


(n, h) = map(int, input().split())
(A, B) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
a = max(A)
B = sorted(list(filter(lambda x: x > a, B)), reverse=True)
ans = 0
while h > 0 and B:
	h -= B[0]
	B.pop(0)
	ans += 1
if h > 0:
	if h % a == 0:
		ans += h // a
	else:
		ans += h // a + 1
print(ans)


import math
(n, h) = map(int, input().split())
A = 0
b = []
ans = 0
for _ in range(n):
	(u, v) = map(int, input().split())
	A = max(A, u)
	b.append(v)
for B in sorted(b, key=lambda x: -x):
	if h <= 0 or B <= A:
		break
	h -= B
	ans += 1
print(max(0, math.ceil(h / A)) + ans)


(n, h) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
a_max = max(a)
b.sort()
ans = 0
for bi in b[::-1]:
	if bi > a_max and h > 0:
		h -= bi
		ans += 1
	else:
		break
if h > 0:
	ans += -(-h // a_max)
print(ans)


(N, H) = map(int, input().split())
Ma = 1
B = []
for i in range(N):
	(a, b) = map(int, input().split())
	B.append(b)
	if a > Ma:
		Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma and H > 0:
	i += 1
	H -= Mb
	if i == N:
		Mb = 0
	else:
		Mb = B[i]
if H <= 0:
	print(i)
else:
	print(i + int(-(-H // Ma)))


(N, H) = map(int, input().split())
bs = []
maxA = 0
ans = 0
for _ in range(N):
	(a, b) = map(int, input().split())
	maxA = max(maxA, a)
	bs.append(b)
bs.sort(reverse=True)
for b in bs:
	if H <= 0:
		break
	if b > maxA:
		H -= b
		ans += 1
if H > 0:
	ans += -(-H // maxA)
print(ans)


(n, h) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
c = max([a[0] for a in ab])
d = [b[1] for b in ab if b[1] > c]
d.sort()
ans = 0
while len(d) > 0:
	h -= d.pop()
	ans += 1
	if h <= 0:
		print(ans)
		exit()
f = (h + c - 1) // c
print(ans + f)


(N, H) = list(map(int, input().split()))
A = [0] * N
B = [0] * N
for i in range(N):
	(a, b) = list(map(int, input().split()))
	(A[i], B[i]) = (a, b)
a = max(A)
T = 0
ct = 0
B = reversed(sorted(B))
for b in B:
	if b > a:
		ct += 1
		T += b
	if T >= H:
		break
print(ct + max((H - T + a - 1) // a, 0))


(n, h) = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(n)]
th = max(l, key=lambda x: x[0])[0]
l = sorted([i for i in l if i[1] >= th], key=lambda x: -x[1])
(c, v) = (0, 0)
for i in l:
	if v < h:
		v += i[1]
		c += 1
if v < h:
	(a, b) = divmod(h - v, th)
	if b:
		a += 1
	c += a
print(c)


from math import ceil
(N, H) = map(int, input().split())
A = []
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
else:
	a = max(A)
	B.sort()
	B.reverse()
ans = 0
for b in B:
	if H <= 0:
		print(ans)
		break
	if a < b:
		H -= b
		ans += 1
else:
	print(ans + ceil(H / a))


from math import ceil
(n, h) = map(int, input().split())
(A, B) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
a = max(A)
B = sorted(list(filter(lambda x: x > a, B)), reverse=True)
ans = 0
i = 0
l = len(B)
while h > 0 and i < l:
	h -= B[i]
	ans += 1
	i += 1
if h > 0:
	ans += ceil(h / a)
print(ans)


(n, h) = map(int, input().split())
a = 0
b = []
for i in range(n):
	(A, B) = map(int, input().split())
	a = max(A, a)
	b.append(B)
b = sorted(b)[::-1]
for i in range(n):
	if 0 < h and a < b[i]:
		h -= b[i]
		ans = i + 1
	else:
		ans = i
		break
if 0 < h:
	ans += -(-h // a)
print(ans)


(N, H) = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
a_max = max(a)
b.sort(reverse=True)
c = 0
for i in range(N):
	if b[i] > a_max:
		H -= b[i]
		c += 1
	if H <= 0:
		break
if H > 0:
	c += (H + a_max - 1) // a_max
print(c)


import math
from math import gcd, pi, sqrt
INF = float('inf')
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
from collections import Counter, deque

def i_input():
	return int(input())

def i_map():
	return list(map(int, input().split()))

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]
import string

def main():
	(N, H) = i_map()
	l = []
	for _ in range(N):
		(a, b) = i_map()
		l.append([a, b])
	t = [list(i) for i in zip(*l)]
	ans = 0
	M = max(t[0])
	throw = 0
	for i in sorted(t[1], reverse=True):
		if i > M:
			throw += i
			H -= i
			ans += 1
			if H <= 0:
				print(ans)
				return
	i = t[0].index(M)
	if H % M == 0:
		ans += H // M
	else:
		ans += H // M + 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, h) = map(int, input().split())
x = (tuple(map(int, input().split())) for _ in [0] * n)
(a2, b) = ([], [])
for j in x:
	a2.append(j[0])
	b.append(j[1])
a = max(a2)
b = [i for i in b if i > a]
b.sort()
b = b[::-1]
if h <= sum(b):
	(num, i) = (0, 0)
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h + a - 1) // a + len(b)
print(num)


(N, H) = map(int, input().split())
(A, B) = zip(*[tuple(map(int, input().split())) for _ in range(N)])
a = max(A)
B = sorted((b for b in B if b > a), reverse=True)
for (i, b) in enumerate(B, 1):
	H -= b
	if H <= 0:
		ans = i
		break
else:
	ans = len(B) + (H + a - 1) // a
print(ans)


(n, h, *k) = map(int, open(0).read().split())
a = max(k[::2])
b = sorted(k[1::2], reverse=True)
ans = 0
while ans < n and b[ans] > a and (h > 0):
	h -= b[ans]
	ans += 1
if h > 0:
	ans += (h + a - 1) // a
print(ans)


(N, H) = map(int, input().split())
A = []
B = []
for i in range(N):
	(a, b) = map(int, input().split())
	A += [a]
	B += [b]
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = A[0]
count = 0
for i in range(N):
	if B[i] >= C:
		H -= B[i]
		count += 1
		if H <= 0:
			print(count)
			exit()
answer = count - -H // C
print(answer)


from math import ceil
(n, h, *AB) = map(int, open(0).read().split())
a = max(AB[::2])
B = sorted((b for b in AB[1::2] if a < b))[::-1]
c = 0
for b in B:
	h -= b
	c += 1
	if h <= 0:
		break
else:
	c += ceil(h / a)
print(c)


(N, H) = map(int, input().split())
A = []
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
max_a = max(A)
B.sort(key=lambda b: -b)
ans = 0
for b in B:
	if b < max_a:
		break
	H -= b
	ans += 1
	if H <= 0:
		print(ans)
		return
ans += (H - 1) // max_a + 1
print(ans)


(N, H) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab = list(zip(*ab))
a = sorted(ab[0], reverse=True)
b = sorted(ab[1], reverse=True)
amax = a[0]
bc = 0
ans = 0
flag = True
while H > 0 and flag:
	bmax = b[bc]
	if bmax > amax:
		H -= bmax
		bc += 1
		if bc == N:
			flag = False
		ans += 1
	else:
		flag = False
if H > 0:
	ans += (H + amax - 1) // amax
print(ans)


(n, h, *L) = map(int, open((x := 0)).read().split())
a = max(L[::2])
b = sorted(L[1::2])
while b and b[-1] > a > 0 < h:
	h -= b.pop()
	x += 1
print(x - -h // a * (h > 0))


import math
(N, H) = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
p = 0
cnt = 0
nokori = 0
b.sort(reverse=True)
maxi = max(a)
for th in b:
	if p >= H:
		break
	elif th > maxi:
		p += th
		cnt += 1
else:
	nokori = math.ceil((H - p) / maxi)
print(cnt + nokori)


(N, H) = map(int, input().split())
(a, b) = ([0] * N, [0] * N)
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
ma = max(a)
b.sort(reverse=True)
ans = 0
index = 0
while H > 0 and len(b) > index and (b[index] > ma):
	H -= b[index]
	index += 1
	ans += 1
if H > 0:
	ans += (H + ma - 1) // ma
print(ans)


(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 + max(h - 1, -1) // b + 1)


import math
(N, H) = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
	(A[i], B[i]) = map(int, input().split())
aa = sorted(A, key=lambda x: -x)
bb = sorted(B, key=lambda x: -x)
ans = 0
I = H
mh = max(aa)
for x in bb:
	if x < mh:
		break
	I = I - x
	ans += 1
	if I <= 0:
		break
if I > 0:
	ans += math.ceil(I / max(aa))
print(ans)


(n, h) = map(int, input().split())
xs = [[int(x) for x in input().split()] for _ in range(n)]
a = max((x[0] for x in xs))
ys = sorted((x[1] for x in xs), reverse=True)
for (i, v) in enumerate(ys):
	if v <= a or h <= 0:
		break
	h -= v
else:
	i += 1
j = (max(h, 0) + a - 1) // a
print(i + j)


(N, H) = map(int, input().split())
A = []
B = []
for _ in range(N):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
B.sort(reverse=True)
A.sort(reverse=True)
B = [x for x in B if x > A[0]]
cnt = 0
for i in range(len(B)):
	H -= B[i]
	cnt += 1
	if H <= 0:
		print(cnt)
		exit()
A.sort(reverse=True)
print(cnt - -H // A[0])