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 sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    N, H = Scanner.map_int()
    A = [0] * N
    B = [0] * N
    for i in range(N):
        a, b = Scanner.map_int()
        A[i] = a
        B[i] = b
    A.sort(reverse=True)
    B.sort(reverse=True)
    ans = 0
    for i in range(N):
        if B[i] > A[0]:
            ans += 1
            H -= B[i]
            if H <= 0:
                break
        else:
            break
    H = max(0, H)
    ans += Math.roundUp(H, A[0])
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
n, h = map(int, input().split())
dat = []
dat1 = []
dat2 = []
for i in range(n):
    a,b = map(int, input().split())
    dat.append( [a,b,i])
    dat1.append( [a, i] )
    dat2.append( [b, i] )

dat1.sort(reverse=True)
dat2.sort(reverse=True)




normax = dat1[0][0]
count = 0
for i in range(n):
    
    if dat2[i][0] > normax:
        count = count + 1
        h = h - dat2[i][0]
    if h <= 0:
        break
        

if h > 0:
    import math
    count = count + math.ceil(h / normax)
print(count)

Solution (Python):
N, H = map(int, input().split())
a = []
b = []
for _ in range(N):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
    
a.sort(reverse = True)
b.sort(reverse = True)

for i in range(N):
    if b[i] <= a[0]:
        b = b[:i]
        break
s = 0
if H <= sum(b):
    for i in range(len(b)):
        s += b[i]
        if s >= H:
            ans = i+1
            break
else:
    H -= sum(b)
    ans = len(b) + H // a[0]
    if H  % a[0] != 0:
        ans += 1

print(ans)

Solution (Python):
import math
import copy
N, H = map(int, input().split())
a_max = [list(map(int, input().split())) for _ in range(N)]
b_max = copy.deepcopy(a_max)
b_max.sort(key=lambda x:-x[1])
a_max.sort(key=lambda x:-x[0])
damage = 0
cnt_damage = 0
for i in range(N):
    if damage >= H:
        print(cnt_damage)
        exit()
        
    if b_max[i][1] >= a_max[0][0]:
        damage += b_max[i][1]
        cnt_damage += 1
    else:
        break

cnt_damage += math.ceil((H-damage)/a_max[0][0])

print(cnt_damage)

Solution (Python):
from bisect import bisect

n,h=map(int,input().split())
b=[]
a_max=0
for i in range(n):
  x,y=map(int,input().split())
  b.append(y)
  a_max=max(a_max,x)

b=sorted(b)
lim_inx=bisect(b,a_max)

cnt=0
total=0
inx=n-1
while total<h:
  if inx>=lim_inx:
    total+=b[inx]
    cnt+=1
    inx-=1
  else:
    if (h-total)%a_max==0:
      cnt+=(h-total)//a_max
    else:
      cnt+=(h-total)//a_max+1
    print(cnt)
    exit()
print(cnt)

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

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

a = sorted(a)
b = sorted(b)
strn_a = a[N-1]
damage = [strn_a]
for i in range(bisect.bisect_left(b,strn_a),N):
    damage.append(b[i])

ans = 0
for i in damage[::-1]:
    H -= i
    ans += 1
    if H <= 0:
        break
if H > 0:
    if H % damage[0] == 0:
        ans += H // damage[0]
    else:
        ans += H // damage[0] + 1

print(ans)

Solution (Python):
import math

n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a = sorted(a)[::-1]
b = sorted(b)[::-1]

cnt = 0
for i in b:
    if i > a[0]:
        h -= i
        cnt += 1
        if h <= 0:
            print(cnt)
            exit()

cnt += math.ceil(h/a[0])
print(cnt)

Solution (Python):

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

Solution (Python):
N,H=map(int,input().split())
ab=[]
a=[]
b=[]

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

a.sort(reverse=True)
b.sort(reverse=True)
k=0
cnt=0

while a[0]<b[k]:
    H-=b[k]
    cnt+=1
    if H<=0:
        break
    k+=1
    if k==len(b):
        break


H=max(H,0)

if H%a[0]==0:
    cnt+=H//a[0]
else:
    cnt+=H//a[0]+1

print(cnt)

Solution (Python):
import heapq
import math

n, h = map(int, input().split())
max_a = 0
b = []
sum_b = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x > max_a:
        max_a = x
    b.append(y)
    sum_b += y

b = list(map(lambda x: x*(-1), b))
heapq.heapify(b)
total = 0
flag = False
max_b = 0
for i in range(1, 10**8):
    if len(b) != 0:
        max_b = heapq.heappop(b)*(-1)
    else:
        flag = True
    if max_b < max_a or flag:
        print(i-1 + math.ceil((h - total) / max_a))
        exit()
    else:
        total += max_b
        if total >= h:
            print(i)
            exit()

Solution (Python):
import math
from operator import itemgetter
n,k = map(int,input().split())

lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort(key=itemgetter(1),reverse=True)
ans = 0

x = 0
for i in range(n):
    x = max(x,lst1[i][0])

for i in range(n):
    if lst1[i][1] > x:
        k -= lst1[i][1]
        ans += 1
    if k <= 0:
        print(ans)
        exit()


print(ans + math.ceil(k/x) )

Solution (Python):
import bisect
import math

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

maxA = max(A)
B.sort()
idx_b = bisect.bisect(B, maxA)

if idx_b == N:
    print(math.ceil(H / maxA))
else:
    h = H
    cnt = 0
    for idx in range(N - 1, max(-1, idx_b - 1), -1):
        h -= B[idx]
        cnt += 1
        if h <= 0:
            print(cnt)
            exit()
    print(cnt + math.ceil(h / maxA))

Solution (Python):
N,H = map(int,input().split())
ken = []
for i in range(N):
    a,b = map(int,input().split())
    ken.append((a,b))
ken.sort()
A,B = ken.pop()
ans = 0
for i in range(N-1):
    a,b = ken[i]
    ken[i] = (b,a)
ken.sort()
for i in range(N-1):
    b,a = ken[-i-1]
    if b >= A:
        if b >= B:
            ans += 1
            H -= b
        else:
            ans += 1
            H -= B
            B = 0
            if H > 0:
                ans += 1
                H -= b
    if H <= 0:
        print(ans)
        quit()
if B != 0:
    H -= B
    ans += 1
if H <= 0:
    print(ans)
    quit()
ans += H//A 
if H % A >= 1:
    ans += 1
print(ans)

Solution (Python):
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([i for i in b if a < i], reverse=True)

cnt = 0
for i in b:
    cnt += 1
    h -= i
    if h <= 0:
        print(cnt)
        exit()
print(cnt + (h + a - 1) // a)

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

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

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

c = HP // MA
ans += c

if HP - (c*MA) > 0:
  ans += 1

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
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()
ma = max(A)
from bisect import bisect_left, bisect_right
r = bisect_right(B, ma) 
C = B[r:]
ans = 0
for i in range(len(C)-1,-1,-1):
  H -= C[i]
  ans +=1
  if H<= 0:
    break
if H>0:
  ans += H//ma
  if H%ma!=0:
    ans+=1
print(ans)

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

Solution (Python):
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)
x = max(A)
B = sorted(B, reverse=True)

B_lst = []
for i in range(n):
    if B[i] > x:
        B_lst.append(B[i])
        
cnt = 0
damage = 0
ans = None
for i in range(len(B_lst)):
    damage += B_lst[i]
    cnt += 1
    if damage >= h:
        ans = cnt
        break
ans = cnt
if damage < h:
    ans = cnt + math.ceil((h - damage)/x)
print(ans)

Solution (Python):

import math
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 = sorted(B, reverse=True)
ans = H
for k in range(N):
    H -= B[k]
    if H > 0:
        cnt = math.ceil(H / max_A) + (k + 1)
    else:
        cnt = k + 1
    ans = min(ans, cnt)
print(ans)

Solution (Python):
from math import ceil
n,h = map(int,input().split())
aa = [0]*n
bb = [0]*n
for i in range(n):
    a,b = map(int,input().split())
    aa[i] = a
    bb[i] = b
m = max(aa)
bb.sort(reverse=True)
ans = 0
dmg = 0

for i in range(n):
    if bb[i] < m or dmg >= h:
        break
    dmg += bb[i]
    ans += 1

if dmg < h:
    ans += ceil((h-dmg)/m)

print(ans)

Solution (Python):
N, H = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A, B = [], []
for a, b in AB:
  A.append(a)
  B.append(b)

maxA = max(A)
B_stack = []
for b in B:
  if b > maxA:
    B_stack.append(b)
B_stack.sort()
B_stack = B_stack[::-1]

answer = 0
for b in B_stack:
  H -= b
  answer += 1
  if H <= 0:
    print(answer)
    exit()

answer += -(-H // maxA)
print(answer)

Solution (Python):
N, H = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A, B = [], []
for a, b in AB:
  A.append(a)
  B.append(b)

maxA = max(A)
B_stack = []
for b in B:
  if b > maxA:
    B_stack.append(b)
B_stack.sort()
B_stack = B_stack[::-1]

answer = 0
for b in B_stack:
  H -= b
  answer += 1
  if H <= 0:
    print(answer)
    exit()

answer += -(-H // maxA)
print(answer)

Solution (Python):
N,H = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]
maxa = max(ab[i][0] for i in range(N))
lastb = [ab[i][1] for i in range(N) if ab[i][1] >= maxa]
lastb.sort(reverse=True)
count = 0
while H > 0 and count < len(lastb):
    H -= lastb[count]
    count += 1
if H <= 0:
    print(count)
else:
    count += (H-1)//maxa+1
    print(count)

Solution (Python):
N, H = map(int, input().split())
ablst = [list(map(int, input().split())) for _ in range(N)]
ablst.sort(key=lambda x: x[0])
amax = ablst[-1][0]
ablst.sort(key=lambda x: x[1], reverse=True)
blst = []
for i in range(N):
    if amax <= ablst[i][1]:
        blst.append(ablst[i][1])
    else:
        break

cnt = 0
for i in blst:
    H -= i
    cnt += 1
    if H <= 0:
        break

if H <= 0:
    print(cnt)
else:
    acnt = H // amax
    cnt += acnt
    if H - (amax * acnt) <= 0:
        print(cnt)
    else:
        print(cnt + 1)

Solution (Python):
import math, sys

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, H = map(int,input().split())
    A = [0 for k in range(N)]
    B = [0 for k in range(N)]
    for k in range(N):
        a, b = map(int,input().split())
        A[k] = a
        B[k] = b
    A = sorted(A)[::-1]
    m = A[0]
    B = sorted(B)[::-1]
    c = 0
    for e in B:
        if e > m:
            c += 1
            H -= e
            if H <= 0:
                print(c)
                exit(0)
        else:
            break
    print(c+math.ceil(H/m))
if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
input = sys.stdin.readline

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.sort(reverse = True)
B.sort(reverse = True)

ans = 0

maxA = A[0] 
for b in B:
    if b <= maxA:
        break
    else:
        H -= b
        ans += 1
        if H <= 0:
            print (ans)
            exit()
        
ans += (H + maxA - 1) // maxA

print (ans)

Solution (Python):
from operator import itemgetter

n, h = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)], key=itemgetter(0), reverse=True)

max_a = ab[0][0]
ab_s2 = sorted(ab, key=itemgetter(1), reverse=True)
ans = 0
for a, b in ab_s2:
    if b > max_a:
        h -= b
        ans += 1
        if h <= 0:
            break

if h > 0:
    ans += -(-h // max_a)

print(ans)

Solution (Python):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor


"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
H = gi()

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

for i in range(N):
    A[i] = -gi()
    B[i] = -gi()

A.sort()
B.sort()

ans = 0

for i in range(N):
    if -B[i] >= -A[0] and H > 0:
        H += B[i]
        ans += 1
    else:
        break

if H > 0:
    ans += H // -A[0]
    if H % -A[0]:
        ans += 1
print(ans)

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

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

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

Solution (Python):
import numpy as np
import math
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)

max_a = max(A)
  
C = list(np.array(B)[max_a <= np.array(B)][::-1])
C.sort(reverse=True)

cnt = 0
for c in C:
    if h <= 0:
        break
    cnt += 1
    h -= c

if h > 0:
    cnt += math.ceil(h / max_a)

print(cnt)

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

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


amax=max(A)

b=[]
for i in range(N):
    if B[i]>=amax:
        b.append(B[i])
b.sort()

cnt=0
while b:
    if H>0:
        H-=b.pop()
        cnt+=1
    if H<=0:
        print(cnt)
        exit()

cnt+=-(-H//amax)
print(cnt)

Solution (Python):
import math

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

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

max_a = max(a_list)
b_list.sort(reverse=True)

count = 0
for b in b_list:
    if b > max_a and H > 0:
        count += 1
        H -= b
    else:
        break

if H > 0:
    count += math.ceil(H / max_a)
print(count)

Solution (Python):
n,h=map(int,input().split())
sword=[]
for i in range(n):
    a,b=map(int,input().split())
    sword.append([a,"a"])
    sword.append([b,"b"])
sword.sort()
ans=0
swordi=[0,"b"]
while(h>0):
    if(swordi[1]=="b"):
        swordi=sword.pop()
        ans+=1
        h-=swordi[0]
    else:
        attack=swordi[0]
        ans+= -(-h//attack)
        h-=attack * -(-h//attack)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

N, H = map(int, input().split())
a_max = 0
b = []

for _ in range(N):
    ai, bi = map(int, input().split())
    a_max = max(a_max, ai)
    b.append(bi)

b.sort(reverse=True)
ans = 0

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

ans += (H+a_max-1)//a_max

print(ans)

Solution (Python):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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







l = []
heapify(l)
for _ in range(N):
     x, y = map(int, input().split())
     heappush(l, (-x, -1))
     heappush(l, (-y, 1))

c = 0
while H > 0:
     d, cc = heappop(l)
     d = d * -1
     if cc == 1:
          H -= d
          c += 1
     elif cc == -1:
          c += ceil(H / d)
          H = 0

print(c)

Solution (Python):
N,H=map(int,input().split())
iAB=[]
a_max=(0,0,0)
for i in range(N):
    a,b=map(int,input().split())
    iAB.append((i,a,b))
    if a_max[1]<a or (a_max[1]==a and a_max[2]>b):
        a_max=(i,a,b)






iAB.sort(key=lambda x:x[2], reverse=True)

ans=0 
throw_idx=0 if a_max[0]!=iAB[0][0] else 1 



while H>0:
    if a_max[2]>=H:
        
        
        ans+=1
        break
    if throw_idx<N and iAB[throw_idx][2]>a_max[1]:
        
        H-=iAB[throw_idx][2]
        
        throw_idx+=1
        throw_idx+=1 if throw_idx<N and iAB[throw_idx][0]==a_max[0] else 0
        ans+=1
        continue
    
    
    furi=(H-a_max[2])//a_max[1] +(1 if (H-a_max[2])%a_max[1] else 0)
    
    ans+=furi
    H-=furi*a_max[1]
    if a_max[1]>=H:
        
        
        ans+=1
        break

print(ans)

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

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, readline().split()))
    a, b = [], []
    for i in range(n):
        av, bv = list(map(int, readline().split()))
        a.append(av)
        b.append(bv)
    a.sort()
    b.sort()
    cnt = 0
    while True:
        if h != 0:
            av = a.pop()
            if len(b) != 0:
                bv = b.pop()
                if bv > av:
                    cnt += 1
                    h -= min(h, bv)
                    a.append(av)
                else:
                    cnt += (h + av - 1) // av
                    h = 0
            else:
                cnt += (h + av - 1) // av
                h = 0
        else:
            print(cnt)
            exit()


if __name__ == '__main__':
    solve()

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)

maxA = max(A)

ans = 0
C = sorted(B, reverse=True)
for i in range(N):
    if C[i] <= maxA: break
    if H <=0: break
    H -= C[i]
    ans += 1

if H> 0:
    ans += H//maxA + (1 if H % maxA !=0 else 0)

print(ans)

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)

maxA = max(A)

ans = 0
B.sort(reverse=True)
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 + (1 if H % maxA != 0 else 0)

print(ans)

Solution (Python):
n,h = map(int, input().split())
p = 0
q = []
for i in range(n):
    a,b = map(int, input().split())
    p = max(p,a)
    q.append(b)
ans = 0
q.sort(reverse=True)
i = 0
for b in q:
    if b>p:
        ans +=1
        h -= b
        if h<=0:
            break
    else:
        break

if h<=0:
    pass
else:
    ans += -((-h)//p) 
print(ans)

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)

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

flag = False
damage = 0
count = 0
for d in B:
    if ma < d:
        damage += d
        count += 1
        if damage >= H:
            flag = True
            break

if flag:
    print(count)
else:
    ans = -((damage - H) // ma) + count
    print(ans)

Solution (Python):
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, hit_point = fetch_int_input()
swords = fetch_ints_inputs(N)
SLASH, THROW = 0, 1

max_slash_id, max_slash = -1, -1

for idx, sword in enumerate(swords):
    if max_slash <= sword[SLASH]:
        if max_slash == sword[SLASH] and sword[THROW] < swords[max_slash_id][THROW]:
            continue

        max_slash = sword[SLASH]
        max_slash_id = idx


max_slash_throw = swords[max_slash_id][THROW]

large_throw_swords = list(filter(lambda x: x[THROW] > max_slash, swords[:]))
large_throw_swords.sort(key=lambda x: x[1], reverse=True)

count = 0
is_clear = False

for s in large_throw_swords:

    
    
    
    

    hit_point -= s[THROW]
    count += 1
    if hit_point <= 0:
        break

import math
if hit_point > 0:
    count += math.ceil(hit_point / max_slash)

print(count)

Solution (Python):
from math import ceil
n,h=map(int,input().split())
g=[list(map(int,input().split())) for i in range(n)]
l=[]
ans=0
dm=0
for i in range(n):
  l.append([g[i][0],2])
  l.append([g[i][1],1])
l.sort(reverse=True)
for i in range(2*n):
  if l[i][1]==1:
    dm+=l[i][0]
    ans+=1
    if dm>=h:
      print(ans)
      exit()
  else:
    h-=dm
    ans+=ceil(h/l[i][0])
    print(ans)
    exit()

Solution (Python):
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
from itertools import accumulate

n, H, *ab = map(int, sys.stdin.read().split())
a = ab[::2]
b = ab[1::2]

def main():
    a_max = max(a)
    b.sort()
    needless_cnt = bi_r(b, a_max)
    if needless_cnt == n:
        return (H + a_max - 1) // a_max

    cands = b[needless_cnt:]
    total = list(accumulate(cands[::-1]))

    needed_cnt = bi_l(total, H) + 1
    m = len(total)
    if needed_cnt <= m:
        return needed_cnt
    
    remain = H - total[-1]
    return m + (remain + a_max - 1) // a_max

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
import sys
from operator import itemgetter
input=sys.stdin.readline
n,x=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=list(zip(*a))
t=max(b[0])
a.sort(key=itemgetter(1),reverse=True)
ans=0
for i in range(n):
  if a[i][1]>=t:
    x-=a[i][1]
    ans+=1
  if x<=0:
    print(ans)
    break
else:
  ans+=(x+t-1)//t
  x=0
  print(ans)

Solution (Python):
import sys
import math
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, H = MAP()
	A = [0]*(2*N)

	
	for i in range(N):
		a, b = MAP()
		A[2*i] = a
		A[2*i+1] = b
	
	
	B = [0 if not i%2 else 1 for i in range(2*N)]
	

	
	C = list(zip(A,B))
	

	
	C.sort(reverse=True)

	
	A, B = zip(*C)
	

	ans = 0
	for i, a in enumerate(A):
		if B[i]:
			H -= a
			ans += 1
			if H <= 0:
				break
		else:
			ans += math.ceil(H/a)
			break
	
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, H = MAP()
A = [0] * N
B = [0] * N
for i in range(N):
    a, b = MAP()
    A[i] = a
    B[i] = b

A.sort(reverse=1)
B.sort(reverse=1)

mxa = A[0]
cnt = 0
for b in B:
    if H <= 0 or b <= mxa:
        break
    H = max(0, H-b)
    cnt += 1
cnt += ceil(H, mxa)
print(cnt)

Solution (Python):
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)
A = sorted(A)[::-1]
B = sorted(B)[::-1]
sum1 = 0
cnt = 0
for i in range(N):
  if B[i] >= A[0]:
    sum1 += B[i]
    cnt += 1
    if sum1 >= H:
      print(cnt)
      exit()
  else:
    break
print(math.ceil((H-sum1)/A[0])+cnt)

Solution (Python):
n,h=map(int,input().split())
li=[tuple(map(int,input().split())) for i in range(n)]

zenbu=[]

for i in range(n):
  a=[li[i][0],"a"]
  b=[li[i][1],"b"]
  zenbu.append(a)
  zenbu.append(b)

zenbu.sort(reverse=True)

life=h
ans=0

import math
for i in range(n):
  if zenbu[i][1]=="b":
    life-=zenbu[i][0]
    ans+=1
    if life<=0:
      print(ans)
      exit()
  elif zenbu[i][1]=="a":
    print(ans+math.ceil(life/zenbu[i][0]))
    exit()

ali=[]
for i in range(n):
  ali.append(li[i][0])
ali.sort()

print(ans+math.ceil(life/ali[-1]))