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 os
import time
import re
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]





def solve():
    N, h = map(int, input().split())
    I = [list(map(int, input().split())) for _ in range(N)]
    A = [x[0] for x in I]
    B = [x[1] for x in I]
    A.sort()
    a = max(A)
    B.sort()
    C = B[bisect_left(B, a):]
    s = sum(C)

    count = 0
    for c in reversed(C):
        count += 1
        h -= c
        if h > 0:
            pass
        else:
            break

    if h > 0:
        count += math.ceil(h/a)

    print(count)

if __name__ == "__main__":
    solve()

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

aList = []
bList = []
for count in range(0,N):
    a,b = map(int, input().split())
    aList.append(a)
    bList.append(b)

bList.sort()
bList.reverse()

maxA = max(aList)

count = 0
damage = 0
for b in bList:
    if maxA < b:
        damage+=b
        count+=1
    if damage >= H:
        break

if damage < H:
    remainingHP = H - damage
    count = count + math.ceil(remainingHP / maxA)

print(count)

Solution (Python):
def d_Katana_Thrower(N, H, S):
    import numpy
    import math
    swing = numpy.asarray([x[0] for x in S])
    throw = numpy.asarray([x[1] for x in S])

    swing_max = numpy.max(swing)

    throw_t = throw[throw >= swing_max]
    throw_t = sorted(throw_t, reverse=True)
    hp = H
    ans = 0
    for d in throw_t:
        if hp <= 0:
            break
        hp -= d
        ans += 1

    if hp > 0:
        ans += math.ceil(hp / swing_max)
    return ans
  
N,H=[int(i) for i in input().split()]
S=[[int(i) for i in input().split()] for j in range(N)]
print(d_Katana_Thrower(N, H, S))

Solution (Python):
A = list(map(int,input().split()))
H = A[1]
N = A[0]

a = [0]
b = [0]

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

a.sort(reverse = True)
b.sort(reverse = True)

countb = 0

while(True):
    if(H<=0):
        print(countb)
        exit()
    if (b[countb] > a[0]):
        H -= b[countb]
        countb += 1
        continue
    else:
        break

print(countb + int(H/a[0]) + (0!=H%a[0]))

Solution (Python):
import sys

[n, h] = map(int, raw_input().split())
xs = []
for _ in range(n):
    [a, b] = map(int, raw_input().split())
    xs.append((a, 1))
    xs.append((b, 0))
xs.sort(reverse=True)
c = 0
for (a, b) in xs:
    if b == 0:
        h -= a
        c += 1
        if h <= 0:
            print c
            sys.exit(0)
    else:
        d = h // a
        c += d
        h -= d * a
        if h > 0: c += 1
        print c
        sys.exit(0)

Solution (Python):
import sys
input = sys.stdin.readline
wield = 0
l = []
N,H = map(int,input().split())
for i in range(N):
   a,b = map(int,input().split())
   l.append(b)
   wield = max(a,wield)
l.sort(reverse=True)
ret = 0
for a in l:
   if H <= 0:
      break
   if a > wield:
      ret += 1
      H -= a
   else:
      break
if H > 0:
   ret += (H+wield-1)//wield
print(ret)

Solution (Python):
T=0

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)

for i in range(N):
    if A[0]<=B[i]:
        H-=B[i]
        T+=1
        if H<=0:
            break

if H>0:
    T+=int(H/A[0])
    if H%A[0]>0:
        T+=1

print(T)

Solution (Python):
import math
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)
am = max(a)
b.sort(reverse=True)

count = 0
for i in b:
    if i < am:
        break
    else:
        H -= i
        count += 1
    if H <= 0:
        break
if H > 0:
    count += math.ceil(H/am)
print(count)

Solution (Python):
import math

N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
zan = max(ab)
zan = zan[0]
ab.sort(reverse=True, key=lambda x:x[1])

bunnage = [ab[0][1]]
for i in range(1, N):
    bunnage.append(bunnage[i-1]+ab[i][1])

ans = []

for i in range(len(bunnage)):
    Z = max(H - bunnage[i], 0)
    zan_num = math.ceil(Z/zan)
    ans.append(i+1+zan_num)

print(min(ans))

Solution (Python):
import numpy as np

N, H = tuple(map(int, input().split(sep=" ")))
a = np.zeros((N,), dtype=np.uint32)
b = np.zeros((N,), dtype=np.uint32)
for i in range(N):
    a[i], b[i] = tuple(map(int, input().split(sep=" ")))

a_max_index = np.argmax(a)
a_max = a[a_max_index]
b_sorted_index = np.argsort(-b)
b_sorted = b[b_sorted_index]

s = np.searchsorted(-b_sorted, -a_max)
counter = 0
damage = 0

for b_selected in b_sorted[0:s]:
    damage += b_selected
    counter += 1
    if damage >= H:
        print(counter)
        exit()



p, m = divmod((H - damage), a_max)
if m == 0:
    counter += p
else:
    counter += p + 1

print(counter)

Solution (Python):
A = list(map(int,input().split()))
H = A[1]
N = A[0]

a = [0]
b = [0]

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

a.sort(reverse = True)
b.sort(reverse = True)

countb = 0

while(H > 0):
    if (b[countb] > a[0]):
        H -= b[countb]
        countb += 1
        continue
    else:
        break

if(H<0):
    print(countb)
    exit()
print(countb + int(H/a[0]) + (0!=(H%a[0])))

Solution (Python):
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.sort(reverse=True)  
b.sort(reverse=True)  

lenb=len(b)

for i in range(lenb):
	if a[0] > b[-1]:
		del b[-1]
	else:
		break
cut = 0

for x in b:
	H -= x
	cut +=1
	if(H<=0):
		print(cut)
		quit()

ans = int(H%a[0])


if ans == 0: ans = H/a[0]+cut
else: ans =(H/a[0])+1+cut

print(int(ans))

Solution (Python):
import numpy as np
import math

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

a.sort(reverse=True)
b.sort(reverse=True)
a = np.array(a)
b = np.array(b)
if a[0]>b[-1]:
    for i in range(len(b)-1, -1, -1):
        if a[0]>b[i]:
            b[i] = 0

cum_b = np.cumsum(b)
cum_b = np.unique(cum_b)
del_h = H - cum_b[-1]
'''
print('del_h = ' + str(del_h))
print('len(cum_b) = ' + str(len(cum_b)))
print('cum_b = ' )
print(cum_b)
'''
if del_h<=0:
    for i in range(len(cum_b)):
        if H<=cum_b[i]:
            print(i+1)
            break
else:
    n = math.ceil(del_h/a[0])
    print(len(cum_b) + n)

Solution (Python):
def solve():
    N,H = list(map(int, input().split()))
    az = []
    bz = []
    for i in range(N):
        a,b = list(map(int, input().split()))
        az.append(a)
        bz.append(b)
        
    amax = max(az)
    bz.sort(reverse=True)
    cnt = 0
    for b in bz:
        if amax < b:
            H -= b
            cnt += 1
        if H <= 0:
            return cnt
    if H <= 0:
        return cnt
    cnt += int(H / amax)
    cnt += min(H % amax, 1)
    return cnt
        
print(solve())

Solution (Python):
import numpy as np
N,H=map(int,input().split())
ab=[input().split() for i in range(N)]
a = [int(ab[i][0]) for i in range(N)]
maxa = max(a)
b = np.array([int(ab[i][1]) for i in range(N)])
b_effective = b[b > maxa]
d = 0
if sum(b_effective) < H:
    c = len(b_effective)
    rest = H - sum(b_effective)
    if rest % maxa == 0:
        d = rest//maxa
    else:
        d = rest//maxa + 1
else:
    b = np.sort(b_effective)[::-1]
    s = 0
    for i in range(len(b)):
        s += b[i]
        if s >= H:
            c = i + 1
            d = 0
            break
print(c+d)

Solution (Python):
N,H = map(int,input().split())
katana = []
damage = 0
for n in range(N):
    katana.append(list(map(int,input().split())))

katanaA = sorted(katana,reverse = True)
katanaB = sorted(katana, key = lambda x:x[1],reverse = True)
numb = 0
num = 0
check = True
while damage < H:
    if katanaA[0][0] <= katanaB[numb][1] and check:
        damage += katanaB[numb][1]
        numb += 1
        if numb == N:
            numb = N-1
            check = False
    else:
        num += (H-damage)//katanaA[0][0]
        if  (H-damage)%katanaA[0][0] == 0:
            num -= 1
        damage = H
    num += 1 
print(num)

Solution (Python):
import math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b==[]:
    x+=math.ceil(m/a[0])
    break
  else:
    if b[0]>a[0]:
      m-=b[0]
      del b[0] 
      x+=1
    else:
      x+=math.ceil(m/a[0])
      break
    
print(x)

Solution (Python):
temp=input()
n=int(temp.split(" ")[0])
h=int(temp.split(" ")[1])
a=[]
b=[]
for i in range(n):
    temp=input()
    ta=int(temp.split(" ")[0])
    tb=int(temp.split(" ")[1])
    a.append(ta)
    b.append(tb)
p=max(a) 
c=[]
for temp in b:
    if temp>p:
        c.append(temp)
c.sort(reverse=True)
count=0
for temp in c:
    h-=temp
    count+=1
    if h<=0:
        print (count)
        break

if h>0:
    if h%p==0:
        count+=int(h/p)
        print(count)
    else :
        count+=(int(h/p)+1)
        print(count)

Solution (Python):
n, h = [int(x) for x in input().split()]
sl = 0
b = []
for i in range(n):
  b += [0]
  a, b[-1] = [int(x) for x in input().split()]
  sl = max(sl, a)
b.sort(reverse=True)

res = 0
for th in b:
  if th <= sl:
    break
  h -= th
  res += 1
  if h <= 0:
    break
if h > 0:
  if h % sl == 0:
    res += h // sl
  else:
    res += h // sl + 1
print(res)

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)

a.sort()
b.sort()

x = a[-1]

count = 0
while(h > 0):    
    if b[-1] > x:
        h -= b.pop()
        count += 1;
        if not b:
            b.append(-100)
    else:
        
        
        count += (h // a[-1])
        h -= a[-1] * (h//a[-1])
        break
if h > 0:
    count += 1
print(count)

Solution (Python):
n, h = input().split()
n = int(n)
h = int(h)

a = []
b = []
for i in range(n):
    a_, b_ = input().split()
    a.append(int(a_))
    b.append(int(b_))

import numpy as np
a = np.array(a)
b = np.array(b)

to_throw = b[b>max(a)]
sum_throw = sum(to_throw)

d = h - sum_throw

if d <= 0:
    cum = np.cumsum(np.sort(to_throw)[::-1])
    print(len(to_throw) - len(cum[cum>=h]) + 1)
else:
    import math
    print(len(to_throw) + math.ceil(d/max(a)))

Solution (Python):
import numpy as np
import math

N, H = [int(_) for _ in input().split()]
a_arr=np.zeros(N).astype(int)
b_arr=np.zeros(N).astype(int)
for i in range(N):
    a,b=[int(_) for _ in input().split()]
    a_arr[i]=a
    b_arr[i]=b
    
ma=a_arr.max()

s_arr=np.sort(b_arr)[::-1]
count=0
for i in range(N):
    if (s_arr[i]<=ma) or (H<=0):
        break
    count+=1
    H-=s_arr[i]

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

Solution (Python):
from math import ceil

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

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

maxA = max(As)

ans = 0
for B in reversed(sorted(Bs)):
    if B <= maxA:
        break

    H -= B
    ans += 1
    if H <= 0:
        print(ans)
        exit()

ans += ceil(H / maxA)
print(ans)

Solution (Python):
from bisect import bisect_left, bisect
from itertools import accumulate
from math import ceil


def solve(n, h, aa, bb):
    max_a = max(aa)
    bb.sort()
    i = bisect(bb, max_a)
    if i == n:
        return ceil(h / max_a)
    bba = list(accumulate(reversed(bb[i:])))
    remain = h - bba[-1]
    slash_cnt = max(0, ceil(remain / max_a))
    slash_dmg = slash_cnt * max_a
    throw_dmg = h - slash_dmg
    return slash_cnt + bisect_left(bba, throw_dmg) + 1


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

print(solve(n, h, aa, bb))

Solution (Python):
N, H = map(int, input().split())
a = []
b = []
for i in range(N):
    tmpa, tmpb = map(int, input().split())
    a.append(tmpa)
    b.append(tmpb)
m = max(a)
b.sort(reverse=True)
cnt = 0
for i in b:
    if i > m and H > 0:
        H -= i
        cnt += 1
    else:
        break
if H > 0:
    cnt += H // m
    if H % m != 0:
        cnt += 1
print(cnt)

Solution (Python):
def main():
    l = list(map(int,input().split(" ")))
    N = l[0]
    H = l[1]
    damage = []
    throwDamage = []
    for i in range(N):
        temp = list(map(int,input().split(" ")))
        damage.append(temp[0])
        throwDamage.append(temp[1])
    damage = sorted(damage,reverse=True)
    throwDamage = sorted(throwDamage,reverse=True)
    temp = 0
    count = 0
    for d in throwDamage:
        if d>damage[0]:
            temp+=d
            count+=1
            if temp>=H:
                print(count)
                exit()
    tar = H-temp
    count+=int(tar/damage[0])
    if tar%damage[0]:
        print(count+1)
    else:
        print(count)

if __name__=="__main__":
    main()

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

Solution (Python):
import math
n, h = map(int,input().split())
a=[]
b=[]

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

maxa=max(a)
b.append(maxa)
b.sort()
b.reverse()

damage=0
cnt=0
while(h>damage):
    
    if b[0]>maxa:
        damage+=b[0]
        del b[0]
        cnt+=1
    else:
        cnt=cnt+int((h-damage)/b[0])
        
        damage+=b[0]*int((h-damage)/b[0])
        if h>damage:
            cnt+=1
            damage+=b[0]

print(cnt)

Solution (Python):
from pprint import pprint as pp
import collections
import math

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

a_l = []
b_l = []
for _ in range(n):
  ab = list(map(int, input().split()))
  a_l.append(ab[0])
  b_l.append(ab[1])
a = max(a_l)
b_l = sorted(b_l)

i = 0
while h > 0:
  if b_l and b_l[-1] > a:
    h -= b_l.pop()
    i += 1
  else:
    i += math.ceil(h / a)
    break
print(i)

Solution (Python):
n, H = [int(e) for e in input().split(' ')]

a = []
b = []
for _ in range(n):
  a_i, b_i = [int(e) for e in input().split(' ')]
  a.append(a_i)
  b.append(b_i)

a.sort()
b.sort()
b.reverse()

while len(b) > 0 and b[-1] <= a[-1]:
  b.pop()

ans = 0
for e in b:
  ans += 1
  H -= e
  if H <= 0:
    break

if H > 0:
  ans += (H + a[-1] - 1) // a[-1]

print(ans)

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

Solution (Python):
import math
n, h = map(int,input().split())
thr = []
att = []
ans = 0
for i in range(n):
 a, b = map(int,input().split())
 att.append(a)
 thr.append(b)
thr.sort(reverse = True)
att.sort(reverse = True)


for m in range(n):
 if h > 0:
  if thr[m] > att[0]:
   h = h -thr[m]
   ans = ans+1
  else:
   h = h-att[0]
   ans = ans+1
if h > 0:
 turn = h/att[0]
 turn = math.ceil(turn)
 ans = ans+ turn

print(ans)

Solution (Python):
from bisect import bisect, bisect_left
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bf = list(filter(lambda x: x > max_a, bb))
    if not bf:
        return ceil(h / max_a)
    bf.sort(reverse=True)
    bba = list(accumulate(bf))
    remain = h - bba[-1]
    slash_cnt = max(0, ceil(remain / max_a))
    slash_dmg = slash_cnt * max_a
    throw_dmg = h - slash_dmg
    for i, dmg in enumerate(bba):
        if dmg >= throw_dmg:
            break
    return slash_cnt + i + 1


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

print(solve(h, aa, bb))

Solution (Python):

import sys

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

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

MAX_a = max(a)
bs = sorted(b)[::-1]
ans = 0
for i in bs:
    if(i<=MAX_a):
        break
    ans += 1
    h -= i
    if(h<=0):
        print(ans)
        sys.exit()
ans += h//MAX_a
if(h%MAX_a != 0):ans += 1
print(ans)

Solution (Python):
if __name__ == "__main__":
    N, H = map(int, input().split())
    ab = []
    max_a = 0
    for i in range(N):
        a,b = map(int, input().split())
        max_a = max(max_a, a)
        ab.append([b, a])
    ab.sort()
    ab = list(reversed(ab))
    res = 0
    result = 2 ** 100
    
    for b,_ in ab:
        H -= b
        res += 1
        if H <= 0:
            result = min(result, res)
            break
        tmp = res + H // max_a
        if H % max_a != 0:
            tmp += 1
        result = min(result, tmp)
            
    print (result)

Solution (Python):

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

	max_a = max([x[0] for x in katanas])
	nageru = [x[1] for x in katanas if x[1] >= max_a]
	nageru.sort(reverse = True)

	cnt, h = nageru_attacks(h, nageru)
	if h > 0:
		print(int((h-0.5) // max_a + cnt + 1))
	else:
		print(cnt)

def nageru_attacks(h, nageru):
	for i in range(len(nageru)):
		h -= nageru[i]
		if h <= 0:
			return [i + 1, 0]

	return[i + 1, h]


if __name__ == '__main__':
	main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,h = LI()
    a = []
    b = []
    for _ in range(n):
        c,d = LI()
        a.append(c)
        b.append(d)
    ma = max(a)
    b = sorted(b, reverse=True)
    r = 0
    for c in b:
        if c <= ma:
            break
        r+=1
        h-=c
        if h<=0:
            return r

    r += h//ma
    if h%ma!=0:
        r += 1
    return r

print(main())

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)

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)

Solution (Python):
import math

N,H = map(int,input().split())
alis=[];blis=[]
for c in range(N):
    a,b = map(int,input().split())
    alis.append(a);blis.append(b)
a = max(alis)
blis.sort();blis.reverse()
count = 0
num = 0
for i in blis:
    if num >= H:
        print(count)
        exit()
    if i < a:
        break
    num += i
    count += 1
count += math.ceil((H-num)/a)
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)

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)

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

max_a = max(a)
b_2 = [i for i in b if i > max_a]

b_2.sort(reverse=True)
l = len(b_2)

for i in range(l):
	H -= b_2[i]
	if H <= 0:
		print(i+1)
		exit(0)

ans = l
if H  % max_a == 0:
	ans += (H//max_a)
else:
	ans += ((H//max_a)+1)

print(ans)

Solution (Python):
n, h = [int(t) for t in input().split()]
aa = []
bb = []
for _ in range(n):
    a, b = [int(t) for t in input().split()]
    aa.append(a)
    if b > a:
        bb.append(b)
aa.sort()
bb.sort()

cnt = 0
while h > 0:
    if not bb or aa[-1] >= bb[-1]:
        cnt += (h - 1) // aa[-1] + 1
        break
    else:
        h -= bb.pop()
    cnt += 1
print(cnt)

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

Solution (Python):
N,H = map(int, raw_input().split())
x = [None]*(N*2)
for i in range(N):
  a,b = map(int, raw_input().split())
  x[2*i] = (a, 0)
  x[2*i+1] = (b, 1)
x = sorted(x)[::-1]
ans = 0
for t in x:
  if t[1]==0:
    print ans+(H+t[0]-1)/t[0]
    break
  H -= t[0]
  ans += 1
  if H<=0:
    print ans
    break

Solution (Python):
import heapq
N, H = map(int, input().split())
buki = []
for i in range(N):
  a, b = map(int, input().split())
  heapq.heappush(buki, (-a, False))
  heapq.heappush(buki, (-b, True))

ans = 0
while H > 0:
  attack, once = heapq.heappop(buki)
  attack = -attack
  if once:
    
    H -= attack
    ans += 1
  else:
    n = (H+attack-1) // attack
    
    H -= attack * n
    ans += n

print(ans)

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

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

A = sorted(A, key=lambda x: -x[0])
a = A[0][0]
ans = 0

A = sorted(A, key=lambda x: -x[1])
for i in range(N):
    if H <= 0:
        break
    if A[i][1] > a:
        ans += 1
        H -= A[i][1]

if H > 0:
    ans += (H + a - 1) // a

print(ans)

Solution (Python):



import sys
import math
import numpy as np
n, h = map(int, sys.stdin.readline().strip().split(" "))
a = []
b = []
for _ in range(n):
    _a, _b = map(int, sys.stdin.readline().strip().split(" "))
    a.append(_a)
    b.append(_b)
max_a = max(a)
cnt = 0
b = np.asarray(sorted(b))
b = b[b > max_a]
while h > 0 and len(b) > 0:
    cnt += 1
    h -= b[-1]
    b = b[:-1]
if h > 0:
    cnt += math.ceil(h / max_a)
print(cnt)

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)