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 = map(int, input().split(" "))
a = []
b = []

for i in range(N):
  c, d = map(int, input().split(" "))
  a.append(c)
  b.append(d)
  
amax = max(a)
b.sort()
b.reverse()
bf = [x for x in b if x > amax]

count = 0
judge = 0
for i in bf:
    H -= i
    if H < 0:
        judge = 1
        count += 1
        print(count)
        break
    count += 1

if judge != 1:
    sho = H//amax
    amr = H%amax
    if amr != 0:
        sho += 1
    print(count+sho)

Submission status: Wrong Answer

Solution code:
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.sort(reverse=True)
b.sort(reverse=True)
ans = 0
index = 0
while H > 0 and len(b) > index and b[index] > a[0]:
    H -= b[index]
    index += 1
    ans += 1
ans += (H + a[0] - 1) // a[0]
print(ans)

Submission status: Wrong Answer

Solution code:
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.sort(reverse=True)
b.sort(reverse=True)
ans = 0
index = 0
while len(b) > index and b[index] > a[0]:
    H -= b[index]
    index += 1
    ans += 1
ans += (H + a[0] - 1) // a[0]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

a = []
b = []
result = -1

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

a_max = max(a)
sorted(b).reverse()
b_length = len(b)

for i, bi in enumerate(b):
    if bi < a_max:
        b_length = i

S = 0

for l in range(b_length):
    S += b[l]
    if S >= H:
        result = l + 1
        print(result)
        sys.exit()

j = b_length

result = b_length + int(math.ceil((H - S)/a_max))

print(result)

Submission status: Wrong Answer

Solution code:
import sys

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

a = []
b = []
result = -1

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

a_max = max(a)
sorted(b).reverse()
b_length = len(b)

for i, bi in enumerate(b):
    if bi < a_max:
        b_length = i

S = 0

for l in range(b_length):
    S += b[l]
    if S >= H:
        result = l + 1
        print(result)
        sys.exit()

j = b_length

result = b_length + int((H - S)/a_max)

print(result)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, H = list(map(int, input().split()))
a = []
b = []
for i in range(N):
    ai, bi = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)

a_max = max(a) # 通常攻撃の最大値
b_dmg = [ elem for elem in b if elem > a_max]

H -= sum(b_dmg)
if H % a_max == 0:
    print(int(H/a_max)+len(b_dmg))
else:
    print(int(H/a_max)+1+len(b_dmg))

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

count = 0
tot = 0
ba = filter((lambda x: x > max(aa)), bb)
if sum(ba) == inn[1]:
    print(len(ba))
    exit()
elif sum(ba) > inn[1]:
    for b in sorted(ba, reverse=True):
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            exit()
else:
    tot = sum(ba)
    count = inn[0] + math.ceil((inn[1]-tot)/max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

count = 0
tot = 0
ba = filter((lambda x: x > max(aa)), bb)
if sum(ba) == inn[1]:
    print(len(ba))
    exit()
elif sum(ba) > inn[1]:
    for b in sorted(ba, reverse=True):
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            exit()
else:
    tot = sum(bb)
    count = inn[0]
    count = inn[0] + math.ceil((inn[1]-tot)/max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

count = 0
tot = 0
if min(bb) <= max(aa):
    for b in sorted(bb, reverse=True):
        if b <= max(aa):
            count += math.ceil((inn[1]-tot)/max(aa))
            tot = inn[1]
            print(count)
            exit()
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            exit()
else:
    tot = sum(bb)
    count = inn[0]

if tot >= inn[1]:
    print(count)
else:
    count = inn[0] + math.ceil((inn[1]-sum(bb))/max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

count = 0
tot = 0
if min(bb) <= max(aa):
    for b in sorted(bb, reverse=True):
        if b <= max(aa):
            count += math.ceil((inn[1]-tot)/max(aa))
            tot = inn[1]
            print(count)
            break
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            break
else:
    tot = sum(bb)
    count = inn[0]

if tot >= inn[1]:
    print(count)
else:
    count = inn[0] + math.ceil((inn[1]-sum(bb))/max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

count = 0
tot = 0
if min(bb) <= max(aa):
    for b in sorted(bb, reverse=True):
        if b <= max(aa):
            count += math.ceil((inn[1]-tot)/max(aa))
            tot = inn[1]
            print(count)
            break
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            break
else:
    tot = sum(bb)
    count = inn[0]

if tot < inn[1]:
    count = inn[0] + math.ceil((inn[1]-sum(bb))/max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

if sum(bb) >= inn[1]:
    tot = 0
    count = 0
    for b in sorted(bb, reverse=True):
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            break
else:
    count = inn[0] + math.ceil((inn[1]-sum(bb))/max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

if sum(bb) >= inn[1]:
    tot = 0
    count = 0
    for b in sorted(bb, reverse=True):
        tot += b
        count += 1
        if tot >= inn[1]:
            print(count)
            break
else:
    count = inn[0] + math.ceil((inn[1]-sum(bb))//max(aa))
    print(count)

Submission status: Wrong Answer

Solution code:
import re
import math
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    return int(comb(n, r-1) * (n-r+1) / r)

if __name__ == '__main__':
    
    N, H = [int(x) for x in input().split()]
    A = []
    B = []
    for i in range(N):
        ta, tb = [int(x) for x in input().split()]
        A.append(ta)
        B.append(tb)

    B = sorted(B)
    B.reverse()
    maxA = max(A)

    cntAtk = 0
    dmg = 0
    for b in B:
        if b <= maxA:
            break
        cntAtk += 1
        dmg += b
        print('atk B', b)
        if dmg >= H:
            print(cntAtk)
            exit()

    print('throwed', dmg, H)
    print('maxA', maxA)
    cntAtk += math.ceil((H-dmg) / maxA)
    print(cntAtk)

Submission status: Wrong Answer

Solution code:
n, h = map(int, raw_input().split())
a, b = [], []
for x in xrange(n):
    ta, tb = map(int, raw_input().split())
    a.append(ta)
    b.append(tb)
ma, s = max(a), 0
o = sorted([_ for _ in b if _ > ma])[::-1]
for i, _ in enumerate(o):
    if s >= h:
        print i + 1
    s += _
print len(o) + (h - s) / ma + int(bool((h - s) % ma)) if s < h else len(o)

Submission status: Wrong Answer

Solution code:
n, h = map(int, raw_input().split())
a, b = [], []
for x in xrange(n):
    ta, tb = map(int, raw_input().split())
    a.append(ta)
    b.append(tb)
ma = max(a)
o = [_ for _ in b if _ > ma]
rest = h - sum(o)
print len(o) + rest / ma + int(bool(rest % ma)) if rest > 0 else len(o)

Submission status: Wrong Answer

Solution code:
n, h = map(int, raw_input().split())
a, b = [], []
for x in xrange(n):
    ta, tb = map(int, raw_input().split())
    a.append(ta)
    b.append(tb)
ma = max(a)
o = [_ for _ in b if _ >= ma]
rest = h - sum(o)
print len(o) + rest / ma + int(bool(rest % ma))

Submission status: Wrong Answer

Solution code:
n, h = map(int, raw_input().split())
a, b = [], []
for x in xrange(n):
    ta, tb = map(int, raw_input().split())
    a.append(ta)
    b.append(tb)
ma = max(a)
o = [_ for _ in b if _ > ma]
rest = h - sum(o)
print len(o) + rest / ma + int(bool(rest % ma))

Submission status: Wrong Answer

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-
import numpy as np

nh = raw_input()
nh = nh.split()
n,h = map(int,nh)

a = np.zeros(n,int)
b = np.zeros(n,int)

for i in range(n):
    line = raw_input()
    line = line.split()
    line = map(int,line)
    a[i] = line[0]
    b[i] = line[1]

ans = 0
while h > 0:
    #print a,b,ans,h,
    if np.max(b) > np.max(a):
        h -= np.max(b)
        ans += 1
        b[np.where(b==np.max(b))] = 0
        #print "nageru"
    else:
        ans += h / np.max(a)
        if not h % np.max(a) == 0:
            ans += 1
        h = 0
        #print "huru"

print ans

Submission status: Wrong Answer

Solution code:
num, hp = (int(i) for i in input().split(" "))

katanas_a = []
katanas_b = []

for i in range(num):
    a, b = (int(j) for j in input().split(" "))
    katanas_a.append(a)
    katanas_b.append(b)

katanas_a.sort()
swing_max = katanas_a[len(katanas_a) - 1]

katanas_b.sort()

attack_count = 0
for katana in reversed(katanas_b):
    if katana >= swing_max and hp > 0:
        hp -= katana
        attack_count += 1

if hp % swing_max != 0:
    attack_count += int(hp / swing_max) + 1
else:
    attack_count += int(hp / swing_max)

print(attack_count)

Submission status: Wrong Answer

Solution code:
num, hp = (int(i) for i in input().split(" "))

katanas_a = []
katanas_b = []

for i in range(num):
    a, b = (int(j) for j in input().split(" "))
    katanas_a.append(a)
    katanas_b.append(b)

katanas_a.sort()
swing_max = katanas_a[len(katanas_a) - 1]

katanas_b.sort()

attack_count = 0
for katana in reversed(katanas_b):
    if katana > swing_max and hp > 0:
        hp -= katana
        attack_count += 1

count = hp % swing_max

if hp % swing_max != 0:
    attack_count += int(hp / swing_max) + 1
else:
    attack_count += int(hp / swing_max)

print(attack_count)

Submission status: Wrong Answer

Solution code:
num, hp = (int(i) for i in input().split(" "))

katanas_a = []
katanas_b = []

for i in range(num):
    a, b = (int(j) for j in input().split(" "))
    katanas_a.append(a)
    katanas_b.append(b)

katanas_a.sort()
swing_max = katanas_a[len(katanas_a) - 1]

katanas_b.sort()

attack_count = 0
for katana in reversed(katanas_b):
    if katana > swing_max:
        hp -= katana
        attack_count += 1

count = hp % swing_max

if hp % swing_max != 0:
    attack_count += int(hp / swing_max) + 1
else:
    attack_count += int(hp / swing_max)

print(attack_count)

Submission status: Wrong Answer

Solution code:
num, hp = (int(i) for i in input().split(" "))

katanas_a = []
katanas_b = []

for i in range(num):
    a, b = (int(j) for j in input().split(" "))
    katanas_a.append(a)
    katanas_b.append(b)

katanas_a.sort()
swing_max = katanas_a[len(katanas_a) - 1]

attack_count = 0
for katana in katanas_b:
    if katana > swing_max:
        hp -= katana
        attack_count += 1

count = hp % swing_max

if hp % swing_max != 0:
    attack_count += int(hp / swing_max) + 1
else:
    attack_count += int(hp / swing_max)

print(attack_count)

Submission status: Wrong Answer

Solution code:
import numpy as np
import pdb

'''
Answer is "permutation invariant".
'''

def main():
    [N,HP] = map(int,raw_input().split(' '))
    As = np.zeros(N).astype(int)
    Bs = np.zeros(N).astype(int)
    for k in range(N):
        [a,b] = map(int,raw_input().split(' '))
        As[k] = a
        Bs[k] = b

    answer = shortestkill(As,Bs,HP)
    print answer


def shortestkill(As, Bs, HP):
    weaponlist = np.ones(len(Bs))
    maxattack = np.max(As)
    maxthrow = np.max(Bs)

    throworder = np.argsort(Bs)
    orderB = Bs[throworder]
    orderA = As[throworder]
    bestattacksword = np.where(orderA == maxattack)[0][0]
    worththrowing = list(np.where(orderB >= maxattack)[0])

    totaldamage = 0
    idxround = 0
    worththrowing.remove(bestattacksword)
    bestswordisused = False
    while(HP > 0):
        if len(worththrowing) > 0:
            HP -= orderB[worththrowing[0]]
            idxround += 1
            totaldamage  += orderB[worththrowing[0]]
            worththrowing.remove(worththrowing[0])
        elif bestswordisused is False:
            HP -= orderB[bestattacksword]
            totaldamage +=  orderB[bestattacksword]
            idxround +=1
            bestswordisused = True
        else:
            lastattacks = int(np.ceil(float(HP)/float(maxattack)))
            idxround += lastattacks
            HP -= lastattacks * maxattack
            totaldamage +=  lastattacks * maxattack

    return idxround







if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split(' '))
katana = [map(int, input().split(' ')) for _ in range(N)]
dmg_wield, dmg_throw = zip(*katana)

dmg_wield_max = max(dmg_wield)
dmg_throw = [d for d in dmg_throw if d > dmg_wield_max]

n = 0
while H > 0 and dmg_throw:
    H -= dmg_throw.pop()
    n += 1

print(n + max(H-1, -1) // dmg_wield_max + 1)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split(' '))
katana = [map(int, input().split(' ')) for _ in range(N)]
dmg_wield, dmg_throw = zip(*katana)

dmg_wield_max = max(dmg_wield)
dmg_throw = [d for d in dmg_throw if d >= dmg_wield_max]

n = 0
while H > 0 and dmg_throw:
    H -= dmg_throw.pop()
    n += 1

print(n + max(H-1, -1) // dmg_wield_max + 1)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split(' '))
katana = [map(int, input().split(' ')) for _ in range(N)]
dmg_wield, dmg_throw = zip(*katana)

dmg_wield_max = max(dmg_wield)
dmg_throw = [d for d in sorted(dmg_throw, reverse=True) if d >= dmg_wield_max]

n_throw = len(dmg_throw)
H -= sum(dmg_throw)
n_wield = int(H // dmg_wield_max)

if H - dmg_wield_max * n_wield > 0:
    n_wield += 1

print(n_throw + n_wield)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split(' '))
katana = [map(int, input().split(' ')) for _ in range(N)]
dmg_wield, dmg_throw = zip(*katana)

dmg_wield_max = max(dmg_wield)
dmg_throw = [d for d in sorted(dmg_throw, reverse=True) if d >= dmg_wield_max]

n = len(dmg_throw)
H -= sum(dmg_throw)
n += int(H // dmg_wield_max)

if H - dmg_wield_max * n > 0:
    n += 1

print(n)

Submission status: Wrong Answer

Solution code:
import sys
import math
s_ls = sys.stdin.read().split("\n")[:-1]
a = []
b = []
hp = int(s_ls[0].split()[1])
max_slash = 0
for element in s_ls[1:]:
    slash = int(element.split()[0])
    if slash > max_slash:
        max_slash = slash
    b.append(int(element.split()[1]))
bp = sorted([x for x in b if x > max_slash])[::-1]
count = 0
for e in bp:
    hp -= e
    count += 1
    if hp < 0:
        break
if hp > 0:
    count += math.ceil(hp / max_slash)

print(int(count))

Submission status: Wrong Answer

Solution code:
import sys
import math
s_ls = sys.stdin.read().split("\n")[:-1]
a = []
b = []
hp = int(s_ls[0].split()[1])
max_slash = 0
for element in s_ls[1:]:
    slash = int(element.split()[0])
    if slash > max_slash:
        max_slash = slash
    b.append(int(element.split()[1]))
bp = sorted([x for x in b if x > max_slash])[::-1]
count = 0
for e in bp:
    hp -= e
    count += 1
    if hp < 0:
        break
if hp > 0:
    count += math.ceil(hp / max_slash)

print(count)

Submission status: Wrong Answer

Solution code:
N,H=map(int,raw_input().split())
c=[]
for i in range(N):
	a,b=map(int,raw_input().split())
	c.append((a,0))
	c.append((b,1))

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

cnt=0
for i,j in c:
	if j==1:
		H-=i
		cnt+=1
	else:
		if H%i==0:
			cnt+=H/i
			break
		else:
			cnt+=H/i+1
			break
print cnt

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N,H=[int(i) for i in input().split()]

a = [0 for i in range(N)]
b = [0 for i in range(N)]
ll = []
for i in range(N):
    x,y=([int(i) for i in input().split()])
    ll.append([x,y])
    a[i] = x
    b[i] = y
amax = max(a)
bmax = max(b)

lll=sorted(ll,key=lambda x: x[1])


amaxind = [i for i in range(N) if lll[i][0] == amax]
#print(amaxind)
#print(lll)
c=0
while H > 0:
    if lll[-1][0] != amax:
        X = lll.pop()
        H -= X[1]
        c +=1
#        print(H,c)
    else:
        if len(amaxind) > 1:
            X = lll.pop()
            H -= X[1]
            c +=1
            amaxind.pop()
#            print(amaxind)
        else:
            if H <= lll[-1][1]:
                H = 0
                c +=1
            else:
                num = (H-lll[-1][1]-1)//lll[-1][0]
                H -= (num+1) * lll[-1][0]
                c += num+1
#        print(H,c)
print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

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

la, lb = [], []

for i in range(N):
    a, b = list(map(int, input().split()))
    la.append(a)
    lb.append(b)

lb = sorted(lb, reverse=True)
ma, c = max(la), 0

print()

for d in lb:
    if d < ma or H < 0:
        break
    H -= d
    c += 1

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

print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

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

la, lb = [], []

for i in range(N):
    a, b = list(map(int, input().split()))
    la.append(a)
    lb.append(b)

lb = sorted(lb, reverse=True)
ma, c = max(la), 0
for x in lb:
    if x < ma:
        break
    H -= x
    c += 1

print(c + math.ceil(H / ma))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

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

la, lb = [], []

for i in range(N):
    a, b = list(map(int, input().split()))
    la.append(a)
    lb.append(b)

lb = sorted(lb, reverse=True)
lb = list(filter(lambda x:x > max(la), lb))

for i in range(1, len(lb) + 1):
    H -= lb[-1 * i]
    if H <= 0:
        print(i)

if H > 0:
    print(i + math.ceil(H / max(la)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N,H=[int(i) for i in input().split()]

a = [0 for i in range(N)]
b = [0 for i in range(N)]
ll = []
for i in range(N):
    x,y=([int(i) for i in input().split()])
    ll.append([x,y])
    a[i] = x
    b[i] = y
amax = max(a)
bmax = max(b)

lll=sorted(ll,key=lambda x: x[1])


amaxind = [i for i in range(N) if lll[i][0] == amax]

c=0
while H > 0:
    if lll[-1][0] != amax:
        X = lll.pop()
        H -= X[1]
        c +=1
  #      print(H)
    else:
        if len(amaxind) > 1:
            X = lll.pop()
            H -= X[1]
            c +=1
            amaxind.pop()
        else:
            if H <= lll[-1][1]:
                H = 0
                c +=1
            else:
                num = (H-lll[-1][1]-1)//lll[-1][0]
                H -= (num+1) * lll[-1][0]
                c += num+1
 #       print(H)
print(c)

Submission status: Wrong Answer

Solution code:
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)
b2 = list(filter(lambda x:x>max_a,b))
count = len(b2)
H -= sum(b2)
count += (H-1)//max_a + 1
print(count)

Submission status: Wrong Answer

Solution code:
setting = input().rstrip().split(" ")
katana_count = int(setting[0])
HP = int(setting[1])

katana_attack = []
katana_throw = []

for i in range(katana_count):
    katana_status = input().rstrip().split(" ")
    katana_attack.append(int(katana_status[0]))
    katana_throw.append(int(katana_status[1])) 

throw = 0
attack = 0
max_katana_attack = max(katana_attack)
over_attack = []

for i in range(katana_count):
    if katana_throw[i] > max_katana_attack:
        over_attack.append(katana_throw[i])

over_attack.sort(reverse=True)

for a in over_attack:
    throw += 1
    HP = HP - a 
    if HP < 0 :
        break

if HP % max_katana_attack != 0:
    attack = int(HP / max_katana_attack) +1
else:
    attack = int(HP / max_katana_attack)

print(attack + throw)

Submission status: Wrong Answer

Solution code:
setting = input().rstrip().split(" ")
katana_count = int(setting[0])
HP = int(setting[1])

katana_attack = []
katana_throw = []

for i in range(katana_count):
    katana_status = input().rstrip().split(" ")
    katana_attack.append(int(katana_status[0]))
    katana_throw.append(int(katana_status[1])) 

throw = 0
attack = 0
throw_damege = 0
max_katana_attack = max(katana_attack)
for i in range(katana_count):
    if katana_throw[i] > max_katana_attack:
        throw +=1
        throw_damege += katana_throw[i]
        HP = HP - katana_throw[i]
        if HP < 0:
            break

if HP % max_katana_attack != 0:
    attack = int(HP / max_katana_attack) +1
else:
    attack = int(HP / max_katana_attack)

print(attack + throw)

Submission status: Wrong Answer

Solution code:
setting = input().rstrip().split(" ")
katana_count = int(setting[0])
HP = int(setting[1])

katana_attack = []
katana_throw = []

for i in range(katana_count):
    katana_status = input().rstrip().split(" ")
    katana_attack.append(int(katana_status[0]))
    katana_throw.append(int(katana_status[1])) 

throw = 0
attack = 0
throw_damege = 0
max_katana_attack = max(katana_attack)
for i in range(katana_count):
    if katana_throw[i] > max_katana_attack:
        throw +=1
        throw_damege += katana_throw[i]

HP = HP - throw_damege
if HP >0 :
    if HP % max_katana_attack != 0:
        attack = int(HP / max_katana_attack) +1
    else:
        attack = int(HP / max_katana_attack)

print(attack + throw)

Submission status: Wrong Answer

Solution code:
setting = input().rstrip().split(" ")
katana_count = int(setting[0])
HP = int(setting[1])

katana_attack = []
katana_throw = []

for i in range(katana_count):
    katana_status = input().rstrip().split(" ")
    katana_attack.append(int(katana_status[0]))
    katana_throw.append(int(katana_status[1])) 

throw = 0
attack = 0
throw_damege = 0
max_katana_attack = max(katana_attack)
for i in range(katana_count):
    if katana_throw[i] >= max_katana_attack:
        throw +=1
        throw_damege += katana_throw[i]

HP = HP - throw_damege
if HP >0 :
    if HP % max_katana_attack != 0:
        attack = int(HP / max_katana_attack) +1
    else:
        attack = int(HP / max_katana_attack)

print(attack + throw)

Submission status: Wrong Answer

Solution code:
setting = input().rstrip().split(" ")
katana_count = int(setting[0])
HP = int(setting[1])

katana_attack = []
katana_throw = []

for i in range(katana_count):
    katana_status = input().rstrip().split(" ")
    katana_attack.append(int(katana_status[0]))
    katana_throw.append(int(katana_status[1])) 

throw = 0
throw_damege = 0
for i in range(katana_count):
    if katana_throw[i] >= max(katana_attack):
        throw +=1
        throw_damege += katana_throw[i]

HP = HP - throw_damege
attack = int(HP / max(katana_attack))

print(attack + throw)

Submission status: Wrong Answer

Solution code:
setting = input().rstrip().split(" ")
katana_count = int(setting[0])
HP = int(setting[1])

katana_attack = []
katana_throw = []

for i in range(katana_count):
    katana_status = input().rstrip().split(" ")
    katana_attack.append(int(katana_status[0]))
    katana_throw.append(int(katana_status[1]))

Submission status: Wrong Answer

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

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))

ans = 0
while H > 0:
    # まだ投げれる
    if B:
        H -= B.pop()
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)

Submission status: Wrong Answer

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

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))
B.sort(reverse=True)

ans = 0
while H > 0:
    # まだ投げれる
    if B:
        H -= B.pop()
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)

Submission status: Wrong Answer

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

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))

ans = 0
while H > 0:
    # まだ投げれる
    if not B == []:
        H -= B.pop(-1)
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)

Submission status: Wrong Answer

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

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))
B.sort(reverse=True)

ans = 0
while H > 0:
    # まだ投げれる
    if not B == []:
        H -= B[-1]
        del B[-1]
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)

Submission status: Wrong Answer

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

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))
B.sort(reverse=True)

ans = 0
while H > 0:
    # まだ投げれる
    if not B == []:
        H -= B.pop(-1)
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
	c,d = map(int,input().split())
	a.append(c)
	b.append(d)

total = 0
b.sort()
b.reverse()
counter = 0
am = max(a)
for i in b:
	if i >= am:
		total += i
		counter += 1
	else:
		break

if (h-total)%am == 0:
	print(counter+(h-total)//am)
else:
	print(counter+(h-total)//am+1)

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
	c,d = map(int,input().split())
	a.append(c)
	b.append(d)

total = 0
b.sort()
b.reverse()
i = 0
am = max(a)
while i<=n-1 and am < b[i]:
	total += b[i]
	i += 1
if (h-total)%am == 0:
	print(i+(h-total)//am)
else:
	print(i+(h-total)//am+1)

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
	c,d = map(int,input().split())
	a.append(c)
	b.append(d)

total = 0
b.sort()
b.reverse()
i = 0
am = max(a)
while i<=n-1 and am <= b[i]:
	total += b[i]
	i += 1
if (h-total)%am == 0:
	print(i+(h-total)//am)
else:
	print(i+(h-total)//am+1)

Submission status: Wrong Answer

Solution code:
n, h = map(int, input().split())
arr = []
for _ in range(n) :
    a,b = map(int, input().split())
    arr.append((a,-1))
    arr.append((b,1))

arr.sort()
arr.reverse()

cnt = 0
ans = 10**9 + 100
for p in arr :
    if p[1] == -1 :
        # a
        ans = min(ans, cnt + (h+p[0]-1)//p[0])
    elif p[1] == 1 and h>0 :
        # b
        h -= p[0]
        cnt += 1
        if h <= 0 :
            ans = min(ans, cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
N, H = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

b.sort()
m = max(a)
s = [0]
for i in range(N):
    b[i] = max(b[i], m)
    s.append(s[-1] + b[i])
    if s[-1] >= H:
        print(i + 1)
        break
else:
    print(max(N + 1, math.ceil((H - sum(b)) / m) + N))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
N, H = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

b.sort()
m = max(a)
s = [0]
for i in range(N):
    b[i] = max(b[i], m)
    s.append(s[-1] + b[i])
    if s[-1] >= H:
        print(i + 1)
        break
else:
    print(max(N, math.ceil((H - sum(b)) / m) + N))

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())
    AB = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    a = []
    apnd_a = a.append
    b = []
    apnd_b = b.append
    for i, j in AB:
        apnd_a(i)
        apnd_b(j)

    amax = max(a)
    b.sort(reverse=True)
    energy = H
    ans = float('inf')
    for i, j in enumerate(b):
        energy -= j
        x = i + 1
        if energy <= 0:
            print(x)
            return
        x += (energy + amax - 1) // amax
        ans = min(ans, x)
    print(ans)

main()