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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, H, AB):
    ma = max(AB, key=lambda x: x[0])[0]
    AB.sort(key=lambda x: x[1], reverse=True)

    ans = 0
    i = 0
    while H > 0:
        if i < N and AB[i][1] >= ma:
            H -= AB[i][1]
            i += 1
            ans += 1
        else:
            n = int(math.ceil(H / ma))
            H -= ma * n
            ans += n

    return ans


def main():
    N, H = read_int_n()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, H, AB))


if __name__ == '__main__':
    main()

Solution (Python):
from bisect import bisect_right
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)
sortB = sorted(B)
RsortB = sortB[::-1]
L = N - bisect_right(sortB,maxA)
ans = 0
damage_sum = 0
Flag = True
for i in range(L):
    damage_sum = damage_sum + RsortB[i]
    if damage_sum < H:
        ans += 1
        pass
    else:
        ans += 1
        Flag = False
        break
if Flag:
    ans += (H - damage_sum + maxA - 1)//maxA
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
from itertools import accumulate, chain, takewhile

def takeupto(p, xs):
    for x in xs:
        yield x
        if p(x): break

def last(xs):
    for x in xs:
        pass
    return x

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)
ns = takewhile(lambda y: y > a, ys)
ms = chain([0], accumulate(ns))
ps = takeupto(lambda m: m >= h, ms)
i, v = last(enumerate(ps))
r = max(0, h - v)
j = (r // a) + (r % a != 0)
print(i + j)

Solution (Python):
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)

Solution (Python):




class Sword:
    def __init__(self, swing, throw):
        self.swing = swing
        self.throw = throw


def main():
    n, h = map(int, input().split())

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

    s1, s2 = s[:], s[:]
    s1.sort(key=lambda sword: sword.swing, reverse=True)
    s2.sort(key=lambda sword: sword.throw, reverse=True)

    idx, c = 0, 0
    while idx < n and s2[idx].throw >= s1[0].swing and h > 0:
        h -= s2[idx].throw
        c += 1
        idx += 1

    if h > 0:
        c += (h+s1[0].swing-1) // s1[0].swing
    print(c)


if __name__ == '__main__':
    main()

Solution (Python):
import math
N,H = map(int,input().split())
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
y = sorted(y)
xm = max(x)
d = 0
a = 1
while a:
  if xm > y[-a]: 
    a= a-1
    break
  d += y[-a]
  if d>=H:
    break
  if a == N: break
  a +=1
if d>= H:
  print(a)
else:
  e = math.ceil((H-d)/xm)
  print(a+e)

Solution (Python):
N,H = [int(i) for i in input().split()]
a_max = 0
b = []
for i in range(N):
    a_,b_ = [int(i) for i in input().split()]
    if a_max < a_:
        a_max = a_
    b.append(b_)

b.sort()
b  = b[::-1]
ans  = 0 
i=0
while True:
    if a_max > b[i]:
        break
    H -= b[i]
    i +=1
    ans +=1
    if H <=0 or i>=N:
        break



if H >0:
    if H % a_max==0:
        ans += H//a_max
    else:
        ans += H//a_max +1

print(ans)

Solution (Python):
import math
N, H = list(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]
B.sort(reverse=True)

HP = H
ans =0
for b in B:
    if HP<=0:
        print(ans)
        exit()
    if b<a_max:
        break
    HP -=b
    ans+=1


ans += math.ceil(HP/a_max)
print(ans)

Solution (Python):
import math
n,h = map(int,raw_input().split())

arra = []
arrb = []


for i in range(n):
	a , b = map(int,raw_input().split())
	arra.append(a)
	arrb.append(b)

arrb.sort()

l = len(arrb) - 1 
m = max(arra)
count = 0
while arrb[l] > m and -1 < l and h > 0:
	h = max(0,h-arrb[l])
	l -= 1
	count += 1

print count + -(h*-1 // m)

Solution (Python):
n, h = map(int, input().split())
a, b = [], []
for i in range(n):
    normal, throw = map(int, input().split())
    a.append(normal)
    b.append(throw)
a.sort(reverse=True)
b.sort(reverse=True)

count = 0

def check():
    if h <= 0:
        print(count)
        exit()

nage = [x for x in b if x > a[0]]
for v in nage:
    h -= v
    count += 1
    check()

print((h + a[0] - 1) // a[0] + count)

Solution (Python):
import math

N, H = map(int, input().split())
a = []
b = []
for i in range(N):
	ip = list(map(int, input().split()))
	a.append(ip[0])
	b.append(ip[1])

a.sort()
a.reverse()
b.sort()
b.reverse()
ptr = 0
cnt = 0

while(ptr < N and a[0] <= b[ptr]):
	H -= b[ptr]
	ptr+=1
	cnt+=1
	if H <= 0: break

if H > 0: cnt += math.ceil(H / a[0])
print(cnt)

Solution (Python):
from operator import itemgetter
N,H = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
a = max(ab,key=itemgetter(0))[0]
b = sorted([i[1] for i in ab if i[1] > a],reverse=True)
count = 0
for i in b:
    count += 1
    H -= i
    if H <= 0:
        break
if H > 0:
    count += H//a + (0 if H%a==0 else 1)
print(count)

Solution (Python):
def main():
    inf = float('inf')
    mod = 10**9+7
    from itertools import product, permutations, combinations, combinations_with_replacement
    import bisect

    N, H = map(int, input().split())

    katana = [list(map(int, input().split())) for i in range(N)]
    a = max([i[0] for i in katana])
    b = sorted([i[1] for i in katana if a<=i[1]], reverse=True)
    result = 0
    for i in b:
        H -= i
        result += 1
        if H <= 0:
            print(result)
            return

    if a == 1:
        result += H
    else:
        result += H//a + (1 if H%a>=1 else 0)
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):

"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""



N, H = map(int, input().split())

A_max = 0
D_seq = []

for i in range(N):
    A, D = map(int, input().split())
    if A>A_max:
        A_max = A
    D_seq.append(D)

D_sum = 0
D_count = 0
D_seq.sort()
D_seq.reverse()

for i in range(N):
    if D_seq[i] > A_max and D_sum < H:
        D_sum += D_seq[i]
        D_count += 1

A_sum = H-D_sum

if A_sum > 0:
    if A_sum%A_max == 0:
        print(A_sum//A_max + D_count)
    else:
        print(A_sum//A_max + D_count+1)
else:
    print(D_count)

Solution (Python):

a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)


throws=[]
for i in range(1,a+1):
  if ab[i][1]>=ma:
    throws.append(ab[i][1])
throws.sort(reverse=True)


def cel(x):
  if x//1==x:
    return int(x)
  else:
    return int(x)+1


count=0
for i in throws:
  if b>0:
    b-=i
    count+=1
if b>0:
  count+=(cel(b/ma))
print(count)

Solution (Python):
from math import ceil
a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  
ms=[]  
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)


throws=[]
for i in range(1,a+1):
  if ab[i][1]>=ma:
    throws.append(ab[i][1])
throws.sort(reverse=True)


count=0
for i in throws:
  if b>0:
    b-=i
    count+=1
if b>0:
  count+=(ceil(b/ma))
print(count)

Solution (Python):
from math import ceil
a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  
ms=[]  
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)


throws=[]
for i in range(1,a+1):
  if ab[i][1]>=ma:
    throws.append(ab[i][1])
throws.sort(reverse=True)


count=0
for i in throws:
  if b>0:
    b-=i
    count+=1
if b>0:
  count+=(ceil(b/ma))
print(count)

Solution (Python):
from operator import itemgetter

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

a_max = [0, 0]

for i in range(n):
	if katanas[i][0] > a_max[0] or (katanas[i][0] == a_max[0] and katanas[i][1] < a_max[1]):
		a_max = katanas[i]
		a_max_index = i

if a_max_index == 0:
	katanas = katanas[1:]
elif a_max_index == n-1:
	katanas = katanas[:n-1]
else:
	katanas = katanas[:a_max_index] + katanas[a_max_index + 1:]

b_sorted = sorted([katanas[i][1] for i in range(n-1)], reverse=True)

ans = 0

for i in range(n-1):
	if b_sorted[i] <= a_max[0]:
		break
	else:
		ans += 1
		h -= b_sorted[i]
		if h <= 0:
			print(ans)
			break

if h > 0:
	if h <= a_max[1]:
		print(ans + 1)
	else:
		print(ans + (h - a_max[1] -1) // a_max[0] + 2)

Solution (Python):


n,H=map(int,input().split())
S=[]
for i in range(n):
    
    S.append(list(map(int,input().split())))
    
a=[]
b=[]
for i in range(n):
    a.append(S[i][0])

maxa=max(a)    
for i in range(n):
    if(maxa<S[i][1]):
        b.append(S[i][1])

b.sort()
b.reverse()
k=0
count=0
lenb=len(b)
while H>0:
    if lenb>k:
        H-=b[k]
        k+=1
        count+=1
    else:
        
        count+=H//maxa
        if(H%maxa!=0):
            count+=1
        H=0

print(count)

Solution (Python):
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)

maxA = max(a)
b.sort()
b.reverse()

ans=0
index=0
for throwedKatana in b:
    if throwedKatana < maxA:
        break
    H -= throwedKatana
    ans += 1
    if H <= 0:
        break
if H > 0:
    ans += H//maxA
    if H%maxA != 0:
        ans += 1
print(ans)

Solution (Python):
N, H = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]


aArgmax = max(enumerate(L), key=lambda x: x[1][0])[0]  
a, b = L.pop(aArgmax)
L.sort(key=lambda x: x[1])
cnt = 0
while len(L) >= 1 and L[-1][1] > a:
    if H <= 0:
        print(cnt)
        exit()
    if H <= b:
        print(cnt+1)
        exit()
    H -= L.pop()[1]
    cnt += 1

H -= b
cnt += (H+a-1) // a + 1
print(cnt)

Solution (Python):
from bisect import bisect_right,bisect_left
import sys
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,reverse=True)
ama=max(A)

ans =0
for i in range(N):
    if H<=0:
        print(ans)
        sys.exit()
    elif B[i]>=ama:
        H-=B[i]
        ans +=1
    else:
        break
if H>0:
    ans += H//ama
    if H%ama!=0:
        ans +=1
print(ans)

Solution (Python):
from bisect import bisect_right,bisect_left
import sys
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()
ama=max(A)
x = bisect_right(B,ama)
ans = 0
if x ==N:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
    print(ans)
    sys.exit()
for i in range(N-1,x-1,-1):
    if H<=0:
        print(ans)
        sys.exit()
    else:
        H-=B[i]
        ans +=1
if H>0:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
print(ans)

Solution (Python):
import math

N, H = map(int, input().split())
katana = {i: list(map(int, input().split())) for i in range(N)}


max_i, (max_a, max_b) = max(katana.items(), key=lambda x: x[1][0])

ans = 0
for i, (_, b) in sorted(katana.items(), key=lambda x: x[1][1], reverse=True):
    if i == max_i:
        continue
    if H <= max_b or H <= max_a:
        break
    if b < max_a:
        break
    H -= b
    ans += 1

if max_a < max_b and H > 0:
    H -= max_b
    ans += 1
if H > 0:
    ans += math.ceil(H / max_a)

print(ans)

Solution (Python):
import math
N,H=map(int,input().split())
swords = [list(map(int,input().split())) for x in range(N)]
actions = []
for sword in swords:
  actions.append([sword[0],pow(10,9)])
  actions.append([sword[1],1])
actions.sort(key=lambda x:x[0],reverse=True)
count = 0
for action in actions:
  if action[0]*action[1] < H:
    H -= action[0]*action[1]
    count += action[1]
  else:
    count += int(math.ceil(H/action[0]))
    break
print(count)

Solution (Python):
def main():
    N, H = map(int, input().split())
    a = [0 for _ in range(N)]
    b = [0 for _ in range(N)]
    for i in range(N):
        a[i], b[i] = map(int, input().split())

    b.sort()
    b = b[::-1]
    A = max(a)
    count = 0
    for i in range(N):
        if b[i]>A:
            count += 1
            H = H - b[i]
            if H <= 0:
                return count
    
    if H%A==0:
        return count + H//A
    else:
        return count + H//A + 1

if __name__ == "__main__":
    print(main())

Solution (Python):
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)

max_a = max(A)
filtered = [b_i for b_i in B if b_i > max_a]
sum_b = sum(filtered)
if sum_b <= H:
    print(-(-(H - sum_b) // max_a) + len(filtered))
else:
    filtered.sort()
    filtered.reverse()
    s = 0
    for i in range(len(filtered)):
        s += filtered[i]
        if s >= H:
            print(i + 1)
            break

Solution (Python):
a,b = map(int,input().split())
c = 0
s = []
t = []
x = 0
y = 0

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

d = max(s)
t.sort()
t.reverse()

for i in(t):
    if d < i:
        b -= i
        c += 1
        if b <= 0:
            print(c)
            exit()
    elif d >= i:
        c += b//d
        if b%d != 0:
            c += 1
        print(c)
        exit()
    
c += b//d
if b%d != 0:
    c += 1
print(c)

Solution (Python):
from math import ceil
N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB]
A.sort()
B = [i[1] for i in AB]
B.sort()

furudamage = A[-1]
count= 0
while len(B):
    nagedamage = B.pop()
    if nagedamage > furudamage:
        H -= nagedamage
        count += 1
        if H <= 0:
            print(count)
            break
    else:
        break
if H > 0:
    count += ceil(H/furudamage)
    print(count)

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

attack = 0

FWA = max(A)
B.append(0)
B.sort()

while True: 
    D = B.pop()
    if FWA >= D:
        break
    H -= D
    attack += 1
    if H <= 0:
        print(attack)
        sys.exit()

attack += H // FWA
if H % FWA > 0:
    attack += 1

print(attack)

Solution (Python):
n, h = map(int, input().split())
a_d = []
b_d = []
count = 0
for i in range(n):
  a, b = map(int, input().split())
  a_d.append(a)
  b_d.append(b)
a_max = max(a_d)
b_d = sorted(b_d, reverse=True)

while h > 0 and count <= len(b_d)-1:
  if b_d[count] > a_max:
    h -= b_d[count]
    count += 1
  else:
    break

if h <= 0:
  print(count)
else:
  if h % a_max == 0:
    print(count + h // a_max)
  else:
    print(count + h // a_max + 1)

Solution (Python):
n,h = map(int,input().split())
a = []
b = []
ans = 0
for i in range(0,n):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
a.sort(reverse = True)
b.sort(reverse = True)
while h > 0 :
    if(ans == n):
        break
    if(b[ans] < a[0]):
        break
    h -= b[ans]
    ans += 1
if h>0:
    ans += -(-h//a[0])
print(ans)

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

battle = 0
cleared = False

zan_max = 0
nagelist = []
for i in range(N):
    a,b = map(int,input().split())
    if a>zan_max: zan_max = a
    nagelist.append(b)
    
nagelist = sorted(list(filter(lambda x:x>zan_max,nagelist)),reverse=True)

for b in nagelist:
    battle += 1
    H -= b
    if H<=0:
        cleared = True
        break
        
if not cleared:
    if H%zan_max!=0: battle += 1
    battle += H//zan_max
    
print(battle)

Solution (Python):
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()
B.reverse()
Am = max(A)

lo = 0
hi = N-1
while hi - lo > 1:
    mid = (hi+lo)//2
    if B[mid] < Am:
        hi = mid
    else:
        lo = mid
if B[hi] > Am:
    p = hi+1
else:
    p = lo+1

count = 0
for x in B[:p]:
    H-=x
    count += 1
    if H <= 0:
        print(count)
        exit()
count += (H+Am-1)//Am
print(count)

Solution (Python):
n,h = map(int, raw_input().split())
l = [map(int, raw_input().split()) for _ in range(n)]
m = []
for a,b in l:
    m.append((b,0))
    m.append((a,1))
m.sort()
m.reverse()
i = 0
while h > 0 and m[i][1] == 0:
    h -= m[i][0]
    i += 1
if h <= 0:
    print i
else:
    print i + (h + m[i][0] - 1) / m[i][0]

Solution (Python):
import sys
import math

N, H = map(int, input().split())
katana_list = [tuple(map(int, input().split())) for _ in range(N)]
katana_list.sort(reverse=True)
cut_max = katana_list[0][0]

katana_list = [tuple([katana[0], katana[1]]) for katana in katana_list \
               if katana[1] >= cut_max]
katana_list.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for katana in katana_list:
    H -= katana[1]
    cnt += 1
    if H <= 0:
        print(cnt)
        sys.exit()

katana_list.sort(reverse=True)
cnt += math.ceil(H / katana_list[0][0])
print(cnt)

Solution (Python):
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)
b2=sorted(B,reverse=True)
ct=0
for bb in b2:
    if bb>=am:
        H-=bb
        ct+=1
        if H<=0:
            break
    else:
        break
print(ct+(((H//am)+int(H%am!=0)) if H>0 else 0))

Solution (Python):
def solve(n, h, v):
    v = sorted(v, key=lambda x: -x[1])
    opt_a = 0
    opt_b = 0
    opt_i = 0
    for i in range(n):
        a, b = v[i]
        if (opt_a < a) or ((opt_a == a) and (opt_b > b)):
            opt_i = i
            opt_a = a
            opt_b = b
    ans = 0
    for i in range(n):
        a, b = v[i]
        if (i != opt_i) and (opt_a < b):
            h -= b
            ans += 1
            if h <= 0:
                return ans
    if h - opt_b <= 0:
        return ans + 1
    else:
        m = (h - opt_b + opt_a - 1) / opt_a
        return ans + m + 1

n, h = map(int, raw_input().split())
v = [map(int, raw_input().split()) for i in range(n)]
print solve(n, h, v)

Solution (Python):
import math

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_max = max(a)
b.sort(reverse=True)
damage_cnt = 0

while h > 0:
    if len(b) > 0 and b[0] >= a_max:
        h -= b[0]
        b.pop(0)
        damage_cnt += 1
    else:
        damage_cnt += math.ceil(h/a_max)
        h = 0
print(damage_cnt)

Solution (Python):
N, H = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
s = []
for i in range(N):
    a[i], b[i] = map(int, input().split())
    s.append(a[i])
    s.append(b[i])

a.sort(reverse=True)
b.sort(reverse=True)
s.sort(reverse=True)
low=0
high=2*N
t=(low+high) // 2
while(low<=high):
    if s[t] == a[0]:
        break
    elif s[t] < a[0]:
        high=t
    else:
        low=t
    t=(low+high) // 2

m = 0
P = 0
flag = False
for i in range(t+1):
    m+=1
    P+=s[i]
    if P >= H:
        flag = True
        break

if flag == False:
    k = (H-P)//a[0]
    m += k
    P += k * a[0]
    if H > P:
        m+=1

print(m)

Solution (Python):
N, H = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
s = []
for i in range(N):
    a[i], b[i] = map(int, input().split())
    s.append(a[i])
    s.append(b[i])

a.sort(reverse=True)
b.sort(reverse=True)
s.sort(reverse=True)
low=0
high=2*N
t=(low+high) // 2
while(low<=high):
    if s[t] == a[0]:
        break
    elif s[t] < a[0]:
        high=t-1
    else:
        low=t+1
    t=(low+high) // 2

m = 0
P = 0
flag = False
for i in range(t+1):
    m+=1
    P+=s[i]
    if P >= H:
        flag = True
        break

if flag == False:
    k = (H-P)//a[0]
    m += k
    P += k * a[0]
    if H > P:
        m+=1

print(m)

Solution (Python):
if __name__ == '__main__':
    N, H = map(int, input().split())
    values = [map(int, input().split()) for _ in range(N)]
    a, b = zip(*values)

    a = sorted(a)
    b = sorted(b)

    n_attacks = 0
    latter_damage = 0
    while len(b) != 0 and a[-1] < b[-1]:
        n_attacks += 1
        latter_damage += b.pop()

        if H <= latter_damage:
            print(n_attacks)
            exit(0)

    a_max = a.pop()
    
    r = int(bool((H - latter_damage) % a_max))
    n_attacks += r + (H - latter_damage) // a_max
    print(n_attacks)

Solution (Python):
if __name__ == '__main__':
    N, H = map(int, input().split())
    values = [map(int, input().split()) for _ in range(N)]
    a, b = zip(*values)

    
    
    

    
    
    

    a = sorted(a)
    b = sorted(b)

    n_attacks = 0
    latter_damage = 0
    while len(b) != 0 and a[-1] < b[-1]:
        n_attacks += 1
        latter_damage += b.pop()

        if H <= latter_damage:
            print(n_attacks)
            exit(0)

    a_max = a.pop()
    
    r = int(bool((H - latter_damage) % a_max))
    n_attacks += r + (H - latter_damage) // a_max
    print(n_attacks)

Solution (Python):
import math
n,h = (map(int,input().split()))
katanas = [[int(el) for el in input().split()] for _ in range(n)]

hit_max = max([el[0] for el in katanas])

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

count = 0
for katana in katanas:

    

    if h <= 0:
        break
    if katana[1] > hit_max:
        h -= katana[1]
        count += 1
    else:
        break

    
if h <= 0:
    print(count)
else:
    print(count+math.ceil(h/hit_max))

Solution (Python):
n, h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
a,b=[],[]
for x in ab:
    a.append(x[0])
    b.append(x[1])
b.sort()
ans=0
i=0
b = b[::-1]
ma = max(a)
while(h>0 and i<n):
    if b[i]>=ma:
        h-=b[i]
        ans+=1
    i+=1
if h>0:
    if h%ma==0:
        ans+=h//ma
    else:
        ans+=h//ma+1
print(ans)

Solution (Python):





if __name__ == '__main__':
    from math import ceil

    n, h = list(map(int, input().split()))
    a = list()
    b = list()

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

    a_max = max(a)
    bs = sorted([bi for bi in b if bi > a_max], reverse=True)
    remain_hp = h - sum(bs)

    
    
    
    
    if remain_hp > 0:
        print(ceil(remain_hp / a_max) + len(bs))
    else:
        for index, bi in enumerate(bs):
            h -= bi

            if h <= 0:
                print(index + 1)
                break

Solution (Python):
import math
def inpl(): return list(map(int, input().split()))
N, H = inpl()
ab = []
for i in range(N):
    a, b = inpl()
    ab.append([a, 'a'])
    ab.append([b, 'b'])

ans = 0
for i in sorted(ab)[::-1]:
    if H <= 0:
        break
    if i[1] == 'b':
        ans += 1
        H -= i[0]
    else:
        ans += math.ceil(H/i[0])
        H = 0
print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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:
    if h % amax == 0:
        cnt += h // amax
    else:
        cnt += h // amax + 1

print(cnt)

Solution (Python):
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))

Solution (Python):
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)
count=0
for bi in sorted(b, reverse=True):
    if bi<ma:
        break
    count += 1
    H -= bi
    if H<=0:
        break
if H > 0:
    if H%ma == 0:
        count += H//ma
    else:
        count += H//ma +1
print(count)

Solution (Python):
n,h=map(int, input().split())
w=[]
for i in range(n):
    a,b=map(int, input().split())
    w.append([a,b])
w.sort(key=lambda x:x[0],reverse=True)
m=w[0][0]
w.sort(key=lambda x:x[1],reverse=True)

count=0
for i in range(n):
    if w[i][1]>=m:
        count+=1
        h -= w[i][1]
        
    if h<=0:
        print(count)
        break
else:
    print(count+(h+m-1)//m)

Solution (Python):
import math
N, H = map(int, input().split())
cut_max = 0
throw = [0 for _ in range(N)]
throw_max = []
throw_sum = 0
for i in range(N):
    cut, throw[i] = map(int, input().split())
    if cut > cut_max:
        cut_max = cut
throw.sort(reverse=True)
for i in range(N):
    if cut_max < throw[i]:
        throw_max.append(throw[i])
        throw_sum += throw[i]
        if throw_sum >= H:
            print(i+1)
            exit()
    else:
        break
print(len(throw_max) + math.ceil((H-throw_sum)/cut_max))

Solution (Python):
import math

n, h = map(int, input().split())
k = [tuple(map(int, input().split())) for i in range(n)]
k.sort(reverse=True)
mm = k[0][0]


def main():
    c = 0
    count = 0
    for a, b in sorted(k, reverse=True, key=lambda x:(x[1],x[0])):
        if b < mm:
            break
        count += 1
        c += b
        if h <= c:
            print(count)
            return
    print(count + math.ceil((h - c) / mm))


main()

Solution (Python):
n, h = map(int, input().split())
A = []; B = []
for i in range(n):
    a, b = map(int, input().split())
    A += a,; B += b,
a = max(A)

T = []
for i in range(n):
    if a < B[i]:
        T += B[i],
T.sort(reverse=True)
ans = 0
for t in T:
    h -= t; ans += 1
    if h <= 0:
        break
if h > 0:
    ans += (h + a - 1) // a
print(ans)

Solution (Python):
import math
N, H = list(map(int, input().split()))
maxA = 0
b = []
n = 0
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 + math.ceil(max(H,0)/maxA) )

Solution (Python):
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 )

Solution (Python):


N,H=map(int,raw_input().split())
a=[]
b=[]
for i in xrange(N):
 x,y=map(int,raw_input().split())
 a.append(x)
 b.append(y)
b=sorted(b,reverse=True)
amax=max(a)
cnt=0
i=0
while H>0 and i<len(b) and b[i]>amax:
 H=H-b[i]
 cnt+=1
 i+=1
if H>0:
 cnt+=(H+amax-1)/amax
print cnt

Solution (Python):
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)

Solution (Python):
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)