Problem:


Score : 400 points

Problem Statement

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

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

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

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

Constraints

1 ≤ N ≤ 10^5

1 ≤ H ≤ 10^9

1 ≤ a_i ≤ b_i ≤ 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N H
a_1 b_1
:
a_N b_N

Output

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

Sample Input 1

1 10
3 5

Sample Output 1

3

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

Sample Input 2

2 10
3 5
2 6

Sample Output 2

2

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

Sample Input 3

4 1000000000
1 1
1 10000000
1 30000000
1 99999999

Sample Output 3

860000004

Sample Input 4

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

Sample Output 4

9



Sample input:
1 10
3 5


Sample output:
3

Submission status: Wrong Answer

Solution code:
N,H = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(N)]
ma = max(a,key = lambda x:x[0])[0]
cnt = 0
su = 0
for i in range(N):
  if a[i][1]>=ma:
    cnt+=1
    su += a[i][1]
H -= su
cnt+= H//ma
print(cnt)

Submission status: Wrong Answer

Solution code:
N,H = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(N)]
ma = max(a,key = lambda x:x[0])[0]
cnt = 0
su = 0
for i in range(N):
  if a[i][1]>=ma:
    cnt+=1
    su += a[i][1]
H -= su
while H>0:
  H -= ma
  cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,h = (int(i) for i in input().split())
a = []
b = []
cnt = 0
for i in range(n):
  x,y = (int(i) for i in input().split())
  a.append(x)
  b.append(y)
max = max(a)
b.sort()
for i in b[::-1]:
  if i >= max:
    h -= i
    cnt += 1
 #   print(i,h,cnt)
  if h <= 0:
  #  print(cnt)
    exit()
import math
cnt += int(math.ceil(h / max))
print(cnt)

Submission status: Wrong Answer

Solution code:
n,h = (int(i) for i in input().split())
a = []
b = []
cnt = 0
for i in range(n):
  x,y = (int(i) for i in input().split())
  a.append(x)
  b.append(y)
max = max(a)
b.sort()
for i in b[::-1]:
  if i > max:
    h -= i
    cnt += 1

  if h <= 0:

    exit()
import math
cnt += int(math.ceil(h / max))
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
def main():
    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(reverse=True)
    b.sort(reverse=True)

    m = N
    for i in range(N):
        if b[i] > a[0]:
            continue
        else:
            m = i
            break
    
    for i in range(m):
        H -= b[i]
    
    print(math.ceil(H / a[0]) + m)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
def main():
    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(reverse=True)
    b.sort(reverse=True)

    m = N
    for i in range(N):
        if b[i] >= a[0]:
            continue
        else:
            m = i
            break
    
    for i in range(m):
        H -= b[i]
    
    print(math.ceil(H / a[0]) + m)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
def main():
    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(reverse=True)
    b.sort(reverse=True)

    m = N
    for i in range(N):
        if b[i] >= a[0]:
            continue
        else:
            m = i - 1
    
    for i in range(m):
        H -= b[i]
    
    print(math.ceil(H / a[0]) + m)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
def main():
    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(reverse=True)
    b.sort(reverse=True)

    m = N
    for ib in b:
        if ib >= a[0]:
            continue
        else:
            m = i-1
    
    ans = H
    for i in range(m):
        ans -= b[i]
    
    print(math.ceil(ans / a[0]) + m)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():
    N,H = map(int, input().split())
    X = []
    tmp = 0
    for _ in range(N):
        a,b = map(int, input().split())
        X.append((a,b))
        if a > tmp:
            tmp = a
    XA = []
    for x in X:
        if x[0] == tmp:
            XA.append(x)
    XA.sort(key=lambda x: x[1])
    ma = XA[0] # 切る用

    XB = [] # 投げる用
    for x in X:
        if x[1] > ma[1] and x != ma:
            XB.append(x)
    XB.sort(key=lambda x: x[1])
    ans = 0
#    print(ma,XB)
    while H>0:
#        print(H)
        if H - ma[1] <= 0: # final throw
            ans += 1
            break
        if XB:
            H -= XB.pop()[1]
            ans += 1
        else:
            d = math.ceil((H-ma[1])/ma[0])
            H -= d * ma[0]
            ans += d
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    B.sort()
    B.reverse()
    swing = max(A)
    for i in range(N):
        if B[i] > swing:
            H -= B[i]
            count += 1
        if H <= 0:
            break
    swingCount = -(-H // swing)
    count += swingCount

    print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC085 D - Katana Thrower
import numpy as np
n,h = map(int,input().split())
A = []
B = []
ans = 0

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

B = np.array(B)
a = max(A)
B = B[B > a]

for i in range(len(B)):
    if h > 0:
        h -= B[i]
        ans += 1

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

Submission status: Wrong Answer

Solution code:
# ABC085 D - Katana Thrower
import numpy as np
n,h = map(int,input().split())
A = []
B = []
ans = 0

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

B = np.array(B)
a = max(A)
B = B[B > a]

for i in range(len(B)):
    if h > 0:
        h -= B[i]
        ans += 1

if h%a != 0:
    ans += h//a + 1
else:
    ans += h//a

print(ans)

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    swing = max(A)
    for i in range(N):
        if B[i] > swing:
            if H >= 0:
                H -= B[i]
                count += 1
            else:
                break
    if H >= 0:
        swingCount = -(-H // swing)
    else:
        swingCount = 0

    count += swingCount 

    print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    swing = max(A)
    killed = False
    for i in range(N):
        if B[i] > swing:
            H -= B[i]
            count += 1
        if H <= 0:
            killed = True
            break
            
    if killed:
        print(count)
    else:
        print(count - (-H // swing))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    throwTotal = 0
    throwCount = 0
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    swing = max(A)
    for i in range(N):
        if B[i] > swing:
            throwTotal += B[i]
            throwCount += 1
    while H > throwTotal:
        count += 1
        H -= swing
    else:
        count += throwCount
    print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    throwTotal = 0
    throwCount = 0
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    swing = max(A)
    for i in range(N):
        if B[i] > swing:
            throwTotal += B[i]
            throwCount += 1
            
    if H - throwTotal >= 0 and swing != 0:
        life = H - throwTotal
        swingCount = -(-life // swing)

    else:
        swingCount = 0

    count = swingCount + throwCount

    print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    throwTotal = 0
    throwCount = 0
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    swing = max(A)
    for i in range(N):
        if B[i] > swing:
            throwTotal += B[i]
            throwCount += 1
    if H - throwTotal >= 0:
        life = H - throwTotal
        swingCount = -(-life // swing)
    else:
        swingCount = 0

    count = swingCount + throwCount

    print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    A = []
    B = []
    throwTotal = 0
    throwCount = 0
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    swing = max(A)
    for i in range(N):
        if B[i] > swing:
            throwTotal += B[i]
            throwCount += 1
    if H - throwTotal >= 0:
        life = H - throwTotal
        swingCount = life // swing
    else:
        swingCount = 0

    count = swingCount + throwCount

    print(count)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

N, H = map(int, input().split())
bsum = 0
amax = 0
for _ in range(N):
    a, b = map(int, input().split())
    bsum += b
    if a > amax:
        amax = a
if bsum >= H:
    ans = N
else:
    ans = N + (H - bsum) // amax + 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, h, *k = map(int, open(0).read().split())
a = []; b = []
for i, j in zip(*[iter(k)]*2):
    a.append(i)
    b.append(j)

a = sorted(a, reverse = True)
b = sorted(b, reverse = True)

idx = 0
while idx < n and b[idx] > a[0] and h > 0:
    h -= b[idx]
    idx += 1

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

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
l = [[int(i) for i in input().split()] for _ in range(n)]
l2 = sorted(l,key = lambda x :x[0])
min_atk = l2[n-1][0]

l3 = [i[1] for i in l if i[1] > min_atk]
ct = 0
for i in l3:
    if m > 0:
        m -= i
        ct += 1
    else:
        break

if m <= 0:
    print(ct)
else:
    q,r = divmod(m,min_atk)
    ct += (m//min_atk) +( 1 if r > 0 else 0 )
    print(ct)

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x: (x[1]))
l2 = sorted(l,key = lambda x :x[0])

min_atk = l2[n-1][0]
ct = 0
for i in range(len(l)-1,0,-1):
    if l[i][1] >= min_atk and m >= 0:
        m -= l[i][1]
        ct += 1
    else:
        break

if m < 0:
    print(ct)
else:
    q,r = divmod(m,min_atk)
    ct += (m//min_atk) +( 1 if r > 0 else 0 )
    
print(ct)

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x: (x[1]))
l2 = sorted(l,key = lambda x :x[0])

min_atk = l2[n-1][0]
ct = 0
for i in range(len(l)-1,0,-1):
    print(l[i])
    if l[i][1] >= min_atk and m >= 0:
        m -= l[i][1]
        ct += 1
    else:
        break

if m < 0:
    print(ct)
else:
    q,r = divmod(m,min_atk)
    ct += (m//min_atk) +( 1 if r > 0 else 0 )
    
print(ct)

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x: (x[1]))
l2 = sorted(l,key = lambda x :x[0])

min_atk = l2[n-1][0]
ct = 0
for i in range(len(l)-1,0,-1):
    print(l[i])
    if l[i][1] >= min_atk and m >= 0:
        m -= l[i][1]
        ct += 1
    else:
        break

if m < 0:
    print(ct)
elif m%min_atk == 0:
    ct += m//min_atk
else:
    ct += m//min_atk +1
    
print(ct)

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x: (x[1]))
l2 = sorted(l,key = lambda x :x[0])

min_atk = l2[n-1][0]
ct = 0
for i in range(len(l)-1,0,-1):
    if l[i][1] >= min_atk and m >= 0:
        m -= l[i][1]
        ct += 1
    else:
        break
    

if m < 0:
    print(ct)
else:
    ct += m//min_atk
    
print(ct)

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x: (x[1]))

min_atk = l[0][0]
ct = 0
for i in range(len(l)-1,0,-1):
    if l[i][1] >= min_atk and m >= 0:
        m -= l[i][1]
        ct += 1
    else:
        break
    

if m < 0:
    print(ct)
else:
    ct += m//min_atk
    
print(ct)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split())
# N < 10**5
# H < 10**9
# A<=B<=10**9

B = [0]*N
maxA = 0
for i in range(N):
    a, b = [int(x) for x in input().split()]
    B[i] = a, b
    maxA = max(maxA, a)

# 投げる奴の候補
B = sorted([b for a, b in B if b > maxA], reverse=True)

cnt = 0
for b in B:
    cnt += 1
    H -= b
    if H <= 0:
        break
q, r = divmod(H, maxA)
print(cnt + q + (1 if r > 0 else 0))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,H=map(int,input().split())
l=[[-1]*2 for i in range(N)]

for i in range(N):
    a,b=map(int,input().split())
    l[i]=[a,b]
    
l=sorted(l)

count=0
is_killed=False

for i in range(N):
    if l[i][1]>l[-1][0]:
        H-=l[i][1]
        count+=1
    if H<1:
        is_killed=True
        break

if is_killed:
    print(count)
else:    
    print(count-(-H//l[-1][0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,H=map(int,input().split())
l=[[-1]*2 for i in range(N)]

for i in range(N):
    a,b=map(int,input().split())
    l[i]=[a,b]
    
l=sorted(l)

count=0

for i in range(N):
    if l[i][1]>l[-1][0]:
        H-=l[i][1]
        count+=1
        #投げだけで殺せた場合は？

print(count-(-H//l[-1][0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,H=map(int,input().split())
l=[[-1]*2 for i in range(N)]

for i in range(N):
    a,b=map(int,input().split())
    l[i]=[a,b]
    
l=sorted(l)

count=0

for i in range(N):
    if l[i][1]>l[-1][0]:
        H-=l[i][1]
        count+=1

print(count-(-H//l[-1][0]))

Submission status: Wrong Answer

Solution code:
import collections

def main():

    N, H = map(int, input().split())
    sword = []
    for _ in range(N):
        a, b = map(int, input().split())
        sword.append([a, b])
    sword.sort(key = lambda x: x[1], reverse= True)

    count = float('inf')

    # the case with just throwing the swords
    damage = 0
    count1 = 0
    for a, b in sword:
        damage += b
        count1 += 1
        if damage >= H:
            break
    if damage >= H:
        count = min(count, count1)

    sword.sort(key = lambda x: x[0], reverse = True)
    a0, b0 = sword.pop(0)
    sword.sort(key = lambda x: x[1], reverse = True)

    damage = 0
    count2 = 0
    i = 0
    while i < len(sword) and sword[i][1] > a0:
        damage += sword[i][1]
        count2 += 1
        i += 1
    if damage < H:
        c = (H - damage - b0) // a0
        if (H - damage - b0) % a0 != 0:
            c += 1
        count2 += c + 1
        count = min(count, count2)

    return count


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

Submission status: Wrong Answer

Solution code:
def main():

    N, H = map(int, input().split())
    sword = []
    for _ in range(N):
        a, b = map(int, input().split())
        sword.append([a, b])
    sword.sort(key = lambda x: x[1], reverse= True)

    count = float('inf')

    # the case with just throwing the swords
    damage = 0
    count1 = 0
    for a, b in sword:
        damage += b
        count1 += 1
        if damage >= H:
            break
    if damage >= H:
        count = min(count, count1)

    sword.sort(key = lambda x: x[0], reverse = True)
    a0, b0 = sword.pop(0)
    sword.sort(key = lambda x: x[1], reverse = True)

    damage = 0
    count2 = 0
    i = 0
    while i < len(sword) and sword[i][1] > a0:
        damage += sword[i][1]
        count2 += 1
        i += 1
    if damage < H:
        c = (H - damage - b0) // a0
        if (H - damage - b0) % a0 != 0:
            c += 1
        count2 += c + 1
        count = min(count, count2)

    return count

Submission status: Wrong Answer

Solution code:
from collections import deque
n, h = map(int, input().split())
a_list = []
b_list = []
time = 0
for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
a_list.sort()
b_list.sort(reverse=True)
b_stack = deque(b_list)
while h > 0:
    if len(b_stack) > 0:
        if a_list[-1] < b_stack[0]:
            h -= b_stack.popleft()
            time += 1
        else:
            
            time += h // a_list[-1]
            h = 0
    else:        
        time += h // a_list[-1]
        h = 0
    
print(time)

Submission status: Wrong Answer

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

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

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

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
        
        if H <= 0:
            print(ans)
            break
            
    ans += -(-H // max_A)

    print(ans)

main()

Submission status: Wrong Answer

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

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

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

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
            
    ans += H // max_A if H % max_A == 0 else (H // max_A) + 1

    print(ans)

main()

Submission status: Wrong Answer

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

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

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

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
            
    ans += -(-H // max_A)

    print(ans)

main()

Submission status: Wrong Answer

Solution code:
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)

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

score = 0
for i in range(N):
    if B[i] <= A[0]:
        break
    score += B[i]
    if score >= H:
        print(i + 1)
        exit()

print(math.ceil((H - score) / A[0]) + i)

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())
    a = 0
    b = []
    for i in range(N):
        t = list(map(int, input().split()))
        a = max(a, t[0])
        b.append(t[1])
    b = sorted(b, reverse=True)
    # print(a)
    # print(b)
    i = 0
    while b[i] > a:
        H -= b[i]
        i += 1
        if i >= N:
            break
    if H > 0:
        if H%a == 0:
            i += H//a
        else:
            i += H//a + 1
    print(i)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())
    a = 0
    b = []
    for i in range(N):
        t = list(map(int, input().split()))
        a = max(a, t[0])
        b.append(t[1])
    b = sorted(b, reverse=True)
    # print(a)
    # print(b)
    i = 0
    while b[i] > a:
        H -= b[i]
        i += 1
        if i >= N:
            break
    if H%a == 0:
        print(i + H//a)
    else:
        print(i + H//a + 1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, H = map(int, input().split())
    a = 0
    b = []
    for i in range(N):
        t = list(map(int, input().split()))
        a = max(a, t[0])
        b.append(t[1])
    b = sorted(b, reverse=True)
    # print(a)
    # print(b)
    i = 0
    while b[i] > a:
        H -= b[i]
        i += 1
        if i >= N:
            break
    print(i + math.ceil(H / a))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, H = map(int, input().split())
    a = 0
    b = []
    for i in range(N):
        t = list(map(int, input().split()))
        a = max(a, t[0])
        b.append(t[1])
    b = sorted(b, reverse=True)
    # print(a)
    # print(b)
    i = 0
    while b[i] > a:
        i += 1
        if i >= N:
            break
    if i == 0:
        print(math.ceil(H / a))
    else:
        print(i + math.ceil((H-sum(b[:i])) / a))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, H = map(int, input().split())
    a = 0
    b = []
    for i in range(N):
        t = list(map(int, input().split()))
        a = max(a, t[0])
        b.append(t[1])
    b = sorted(b, reverse=True)
    # print(a)
    # print(b)
    i = 0
    while b[i] > a:
        i += 1
        if i >= N:
            break
    print(i + math.ceil((H-sum(b[:i])) / a))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
N,H=(int(x) for x in input().split())
a=[]
b=[]
for n in range(N):
    aa,bb=(int(x) for x in input().split())
    a.append(aa)
    b.append(bb)
b_sort=sorted(b)
a_sort=sorted(a)
count=0
for n in range(N):
    if b[n]>a_sort[N-1]:
        H=H-b[n]
        count+=1
        if H<=0:
            break
if H>0:
    count=count+H//a_sort[N-1]
    if H%a_sort[N-1]>0:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import math
N,H=(int(x) for x in input().split())
a=[]
b=[]
for n in range(N):
    aa,bb=(int(x) for x in input().split())
    a.append(aa)
    b.append(bb)
b_sort=sorted(b)
a_sort=sorted(a)
count=0
for n in range(N):
    if b[n]>a_sort[N-1]:
        H=H-b[n]
        count+=1
        if H<=0:
            break
if H>0:
    count=count+math.ceil(H/a_sort[N-1])
print(count)

Submission status: Wrong Answer

Solution code:

def updiv(x,y):
    if x % y == 0:
        return x // y
    else:
        return x // y + 1


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

now = 0

lis = []
dic = {}

for i in range(N):

    a,b = map(int,input().split())

    lis.append(a)
    lis.append(b)

    dic[a] = float("inf")

    if b in dic:
        dic[b] += 1
    else:
        dic[b] = 1

lis.sort()
lis.reverse()
ans = 0

for i in lis:

    if dic[i] * i < H:
        ans += dic[i]
        H -= dic[i] * i

    else:
        ans += updiv(H,i)
        break

print (ans)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, h = list(map(int, input().rstrip('\n').split()))
    a = []
    b = []
    for i in range(n):
        ta, tb = list(map(int, input().rstrip('\n').split()))
        a.append(ta)
        b.append(tb)
    ma = max(a)
    b.sort()
    cnt = 0
    for i in range(10 ** 20):
        if len(b) != 0:
            pb = b.pop()
            if pb > ma:
                cnt += 1
                h -= pb
            else:
                cnt += ((h + ma - 1) // ma)
                print(cnt)
                exit()
        else:
            cnt += ((h + ma - 1) // ma)
            print(cnt)
            exit()


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
import math

N, H = map(int, input().split())
Swords_a = []
Swords_b = []
amax = 0
for i in range(N):
  
  a, b = map(int, input().split())
  Swords_a.append(a)
  Swords_b.append(b)
  
ma = max(Swords_a)
sb = 0 # bのうち「maより大きい成分」の和

Swords_a = sorted(Swords_a)
Swords_b = sorted(Swords_b)

c = 0
k = 0

for i in range(N):
  if ma < Swords_b[i]:
    sb += Swords_b[i]
    c += 1
  if sb > H:
    k = c
    break

if sb < H:
  print(c + math.ceil((H-sb)/ma))
else:
  print(k)

Submission status: Wrong Answer

Solution code:
import math

N, H = map(int, input().split())
Swords_a = []
Swords_b = []
amax = 0
for i in range(N):
  
  a, b = map(int, input().split())
  Swords_a.append(a)
  Swords_b.append(b)
  
ma = max(Swords_a)
sb = 0 # bのうち「maより大きい成分」の和

Swords_a = sorted(Swords_a)
Swords_b = sorted(Swords_b)

c = 0
k = 0

for i in range(N):
  if ma < Swords_b[i]:
    sb += Swords_b[i]
    c += 1
  if sb >= H:
    k = c
    break

if sb < H:
  print(c + math.ceil((H-sb)/ma))
else:
  print(k)

Submission status: Wrong Answer

Solution code:
import math

N, H = map(int, input().split())
Swords_a = []
Swords_b = []
amax = 0
for i in range(N):
  
  a, b = map(int, input().split())
  Swords_a.append(a)
  Swords_b.append(b)
  
ma = max(Swords_a)
sb = 0 # bのうち「maより大きい成分」の和

Swords_a = sorted(Swords_a)
Swords_b = sorted(Swords_b)

c = 0
k = 0

for i in range(N):
  if ma < Swords_b[i]:
    sb += Swords_b[i]
    c += 1
  if sb >= H:
    k = c

if sb < H:
  print(c + math.ceil((H-sb)/ma))
else:
  print(k)

Submission status: Wrong Answer

Solution code:
NH = input().split()
N = int(NH[0])
H = int(NH[1])
a = []
b = []
for v in range(N):
    L = input().split()
    a.append(L[0])
    b.append(L[1])
a = list(map(int, a))
b = list(map(int, b))
a.sort(reverse = True)
b.sort(reverse = True)
c = 0
count = 0
while c < H:
    if len(b) > 0 and a[0] < b[0]:
        c = c + b.pop(0)
        count = count + 1 
    else:
        break
if c < H:
    count = count -(-((H - c)//a[0]))
print(count)

Submission status: Wrong Answer

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

alist = []
blist = []

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

alist = sorted(alist)[::-1]
blist = sorted(blist)[::-1]

ans = 0
i = 0

while i < len(blist):
  h -= blist[i]
  ans += 1
  if h <= 0:
    print(ans)
    exit()  
  i += 1

if h % alist[0] == 0:
  ans += h // alist[0]
  print(ans)
else:
  ans += (h // alist[0]) + 1
  print(ans)

Submission status: Wrong Answer

Solution code:
n,h = (int(i) for i in input().split())
A,B = [],[]
for _ in range(n):
    a,b = [int(i) for i in input().split()]
    A.append(a)
    B.append(b)
a_max = max(A)
power,ans = 0,0
for b in B:
    if a_max <= b:
        power += b
        ans += 1
        if power>=h: break
if power>=h:
    print(ans)
else:
    h -= power
    ans += h//a_max
    if h%a_max == 0: print(ans)
    else: print(ans+1)

Submission status: Wrong Answer

Solution code:
n,h = (int(i) for i in input().split())
A,B = [],[]
for _ in range(n):
    a,b = [int(i) for i in input().split()]
    A.append(a)
    B.append(b)
a_max = max(A)
power,ans = 0,0
for b in B:
    if a_max <= b:
        power += b
        ans += 1
if power>=h:
    print(ans)
else:
    h -= power
    ans += h//a_max
    if h%a_max == 0: print(ans)
    else: print(ans+1)

Submission status: Wrong Answer

Solution code:
import math


def resolve():
    n, h = map(int, input().split())
    ab = list(list(map(int, input().split())) for _ in range(n))
    ab.sort(key=lambda x: (x[0], x[1]), reverse=True)
    max_a = ab[0][0]
    count = 0
    for a, b in ab[1:]:
        if b > max_a:
            h -= b
            count += 1
    if ab[0][1] > ab[0][0]:
        h -= ab[0][1]
        count += 1
    count += math.ceil(h / max_a)
    print(count)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline

def main():
    N, H = tuple(map(int, input().split()))
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    A, B = zip(*AB)
    x = max(A)
    B = sorted(i for i in B if i >= x)
    ans = 0
    for i in B:
        ans += 1
        H -= i
        if H <= 0:
            break
    else:
        ans += (H + x - 1) // x
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline

def main():
    N, H = tuple(map(int, input().split()))
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    A, B = zip(*AB)
    x = max(A)
    B = [i for i in B if i >= x]
    ans = len(B)
    H -= sum(B)
    ans += (H + x - 1) // x
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline

def main():
    N, H = tuple(map(int, input().split()))
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    A, B = zip(*AB)
    x = max(A)
    B = [i for i in B if i > x]
    ans = len(B)
    H -= sum(B)
    ans += (H + x - 1) // x
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline

def main():
    N, H = tuple(map(int, input().split()))
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    A, B = zip(*AB)
    x = max(A)
    B = [i for i in B if i > x]
    ans = len(B)
    H -= sum(i for i in B if i > x)
    ans += (H + x - 1) // x
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC085D - Katana Thrower
import sys
input = sys.stdin.readline

def main():
    N, H = tuple(map(int, input().split()))
    AB = tuple(tuple(map(int, input().split())) for _ in range(N))
    A, B = zip(*AB)
    C = sorted([(i, 0) for i in A] + [(i, 1) for i in B], reverse=1)
    ans = 0
    for i, t in C:
        if t == 0:
            ans += (H + i - 1) // i
            break
        else:
            ans += 1
            H -= i
    print(ans)


if __name__ == "__main__":
    main()