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):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
# 切るのはmax(a)だけでいい
# 投げるのはbi> max(a)となるb
am=max(A)
b2=sorted(B,reverse=True)
ct=0
for bb in b2:
    if bb>=am:
        H-=bb
        ct+=1
    else:
        break
print(ct+(H//am)+int(H%am!=0))

Submission status: Wrong Answer

Solution code:
import math
N,H=map(int,input().split())
ab=[]
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
    ab.append([a,b])
# 切るのはmax(a)だけでいい
# 投げるのはbi> max(a)となるb
am=max(A)
b2=sorted(B,reverse=True)
ct=0
for bb in b2:
    if bb>am:
        H-=bb
        ct+=1
    else:
        break
print(ct+(H//am)+int(H%am!=0))

Submission status: Wrong Answer

Solution code:
import math
N,H=map(int,input().split())
ab=[]
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
    ab.append([a,b])
# 切るのはmax(a)だけでいい
# 投げるのはbi> max(a)となるb
am=max(A)
b2=sorted(B,reverse=True)
ct=0
for bb in b2:
    if bb>am:
        H-=bb
        ct+=1
    else:
        break
print(ct+math.ceil(H/am))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

count = 0
for katana in katanas:

    if h <= 0:
        break
    if katana[1] > hit_max:
        h -= katana[1]
        count += 1
    else:
        break
    
if h <= 0:
    print(count)
else:
    print(count+math.ceil(count/hit_max))

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem D

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

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

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

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

    # See:
    # https://img.atcoder.jp/abc085/editorial.pdf
    # https://beta.atcoder.jp/contests/abc085/submissions/1970488
    # https://docs.python.jp/3/library/math.html
    if remain_hp > 0:
        print(ceil(remain_hp / a_max) + len(bs))
    else:
        for index, bi in enumerate(bs):
            h -= bi

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

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    n, h = list(map(int, input().split()))
    a = list()
    b = list()

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

    a_max = max(a)
    bs = [bi for bi in b if bi >= a_max]
    attack_count = len(bs)
    remain_hp = h - sum(bs)

    if remain_hp > 0:
        p, q = divmod(remain_hp, a_max)
        attack_count += p

        if p * a_max < remain_hp:
            attack_count += 1

    print(attack_count)

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    n, h = list(map(int, input().split()))
    a = list()
    b = list()

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

    a_max = max(a)
    bs = [bi for bi in b if bi > a_max]
    attack_count = len(bs)
    remain_hp = h - sum(bs)

    if remain_hp > 0:
        p, q = divmod(remain_hp, a_max)
        attack_count += p

        if p * a_max < remain_hp:
            attack_count += 1

    print(attack_count)

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    n, h = list(map(int, input().split()))
    a = list()
    b = list()

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

    a_max = max(a)
    bs = [bi for bi in b if bi > a_max]
    attack_count = len(bs)
    remain_hp = h - sum(bs)

    if remain_hp > 0:
        attack_count += round(remain_hp / a_max)

    print(attack_count)

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()) 
ma = max(a)
count=0
for bi in sorted(b, reverse=True):
    if bi<ma:
        break
    count += 1
    H -= bi
    if H<=0:
        break
if H > 0:
    count += int((H+0.1)//ma)
print(count)

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

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()) 
ma,td,tc,tb = max(a),0,0,[]
for i in range(N):
    if b[i] > ma:
        td = td+b[i]
        tc = tc+1
        tb.append(b[i])
sorted(tb, reverse=True)
if H > sum(tb):
    print((H-td-1)//ma + 1 + tc)
else:
    for i in range(len(tb)):
        H = H - tb[i]
        if H <= 0:
            print(i+1)
            break

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()) 
ma,td,tc = max(a),0,0
for i in range(N):
    if b[i] > ma:
        td = td+b[i]
        tc = tc+1
print((H-td-1)//ma + 1 + tc)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

n,h = [int(i) for i in input().split()]
A=[]
for i in range(n):
    a,b = input().split()
    A.append([int(a),int(b)])
    
A.sort()

max_a,max_b = A.pop()
A.sort(key=lambda x:x[1],reverse=True)
ans = 0
if n ==1:
    if max_b > max_a:
        h -= max_b
        ans += 1
        if h <= 0:
            print(ans)
        else:
            print(ans+math.ceil(h/max_a))
        
    else:
        print(ans+math.ceil(h/max_a))


    
for i in range(n-1):

    if A[i][1] >= max_a:
        ans += 1
        h -= A[i][1]
        if h <= 0:
            print(ans)
            quit()
    else:
        break

    
if max_b > max_a:
    h -= max_b
    ans += 1
    if h <= 0:
        print(ans)
    else:
        print(ans+math.ceil(h/max_a))
        
else:
    print(ans+math.ceil(h/max_a))

Submission status: Wrong Answer

Solution code:
import math

n,h = [int(i) for i in input().split()]
A=[]
for i in range(n):
    a,b = input().split()
    A.append([int(a),int(b)])
    
A.sort()

max_a,max_b = A.pop()
A.sort(key=lambda x:x[1],reverse=True)
ans = 0

for i in range(n-1):

    if A[i][1] >= max_a:
        ans += 1
        h -= A[i][1]
        if h <= 0:
            print(ans)
            quit()

    
if max_b > max_a:
    h -= max_b
    ans += 1
    if h <= 0:
        print(ans)
    else:
        print(ans+math.ceil(h/max_a))
        
else:
    print(ans+math.ceil(h/max_a))

Submission status: Wrong Answer

Solution code:
import math

n,h = [int(i) for i in input().split()]
A=[]
for i in range(n):
    a,b = input().split()
    A.append([int(a),int(b)])
    
A.sort()

max_a,max_b = A.pop()
A.sort(key=lambda x:x[1],reverse=True)
ans = 0

for i in range(n-1):

    if A[i][1] >= max_a:
        ans += 1
        h -= A[i][1]
        if h <= 0:
            print(ans)
            break

    
if max_b > max_a:
    h -= max_b
    ans += 1
    if h <= 0:
        print(ans)
    else:
        print(ans+math.ceil(h//max_a))
        
else:
    print(ans+math.ceil(h//max_a))

Submission status: Wrong Answer

Solution code:
import math

n,h = [int(i) for i in input().split()]
A=[]
for i in range(n):
    a,b = input().split()
    A.append([int(a),int(b)])
    
A.sort()

max_a,max_b = A.pop()
A.sort(key=lambda x:x[1],reverse=True)
ans = 0

for i in range(n-1):
    print(A[i][1])
    if A[i][1] >= max_a:
        ans += 1
        h -= A[i][1]
        if h <= 0:
            print(ans)
            break

    
if max_b > max_a:
    h -= max_b
    ans += 1
    if h <= 0:
        print(ans)
    else:
        print(ans+math.ceil(h//max_a))
        
else:
    print(ans+math.ceil(h//max_a))

Submission status: Wrong Answer

Solution code:
import math
N, H = list(map(int, input().split()))
maxA = 0
b = []
n = 0
for _ in range(N):
    ta, tb = list(map(int, input().split()))
    maxA = max(maxA, ta)
    b.append(tb)
 
b = list(filter(lambda x: x > maxA, b))
b.sort()

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

print(n + math.ceil(max(H,0)//maxA) )

Submission status: Wrong Answer

Solution code:
import math
N, H = list(map(int, input().split()))
maxA = 0
b = []
for _ in range(N):
    ta, tb = list(map(int, input().split()))
    maxA = max(maxA, ta)
    b.append(tb)

b = list(filter(lambda x: x > maxA, b))
b.sort()
b.reverse()
if not b:
    print(math.ceil(H / maxA))
    exit()

slashNum = math.ceil( (H - sum(b)) / maxA )
dmg = slashNum * maxA
for i in range(N):
    dmg += b[i]
    if dmg >= H:
        print(slashNum + i + 1)
        exit()

Submission status: Wrong Answer

Solution code:
import math
N, H = list(map(int, input().split()))
maxA = 0
b = []
for _ in range(N):
    ta, tb = list(map(int, input().split()))
    maxA = max(maxA, ta)
    b.append(tb)

b = list(filter(lambda x: x > maxA, b))
b.sort()
slashNum = math.ceil( (H - sum(b)) / maxA )

dmg = slashNum * maxA
if not b:
    print(math.ceil(H / maxA))
    exit()
for i in range(N):
    dmg += b[-i]
    if dmg >= H:
        print(slashNum + i + 1)
        exit()

Submission status: Wrong Answer

Solution code:
#abc085d

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

Submission status: Wrong Answer

Solution code:
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if a < j[0]: a = j[0]
	b.append(j[1])
num = 0
for j2 in b:
	if j2 >= a:
		h -= j2
		num +=1
if h%a==0: answer = (h-h%a)//a + num
else: answer = (h-h%a)//a + num + 1
print(answer)

Submission status: Wrong Answer

Solution code:
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = [],[]
for j in x:
	a.append(j[0])
	b.append(j[1])
b.sort()
while b[0]<max(a): b = b[1:]
h -= sum(b)
if h%max(a)==0: answer = (h-h%max(a))//max(a) + len(b)
else: answer = (h-h%max(a))//max(a) + len(b) + 1
print(answer)

Submission status: Wrong Answer

Solution code:
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab.sort(key=lambda x:x[1])
ab.sort(key=lambda x:x[0],reverse=True)
mainweapon = ab[0]
del ab[0]
new_ab =[]
for i in range(N-1):
    if ab[i][1] > mainweapon[0]:
        new_ab.append(ab[i])
new_ab.sort(key=lambda x:x[1],reverse=True)

attack = 0
print(new_ab)

for i in range(len(new_ab)):
    H -= new_ab[i][1]
    attack += 1
    if H <= 0:
        break

if H > 0:
    attack += math.ceil((H - mainweapon[1])/mainweapon[0])
    attack += 1

print(attack)

Submission status: Wrong Answer

Solution code:
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab.sort(key=lambda x:x[1])
ab.sort(key=lambda x:x[0],reverse=True)
mainweapon = ab[0]
del ab[0]
new_ab =[]
for i in range(N-1):
    if ab[i][1] > mainweapon[1]:
        new_ab.append(ab[i])
new_ab.sort(key=lambda x:x[1],reverse=True)

attack = 0

for i in range(len(new_ab)):
    H -= new_ab[i][1]
    attack += 1
    if H <= 0:
        break

if H > 0:
    attack += math.ceil((H - mainweapon[1])/mainweapon[0])
    attack += 1

print(attack)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab = np.array(ab)
attack = 0

furu = np.argmax(ab[:,0])
furupower = ab[furu,0]
nageru = np.argmax(ab[:,1])
nagerupower = ab[nageru,1]

#投げる
while not(furupower >= nagerupower or furu == nageru or H <= 0):
    H -= nagerupower
    ab = np.delete(ab, nageru, 0)
    furu = np.argmax(ab[:,0])
    furupower = ab[furu,0]
    nageru = np.argmax(ab[:,1])
    nagerupower = ab[nageru,1]
    attack += 1
#振る
if H > 0:
    attack += math.ceil((H - nagerupower)/furupower)

#投げる
if H > 0:
    attack += 1
print(attack)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab = np.array(ab)
attack = 0

furu = np.argmax(ab[:,0])
furupower = ab[furu,0]
nageru = np.argmax(ab[:,1])
nagerupower = ab[nageru,1]

#投げる
while not(furupower >= nagerupower or furu == nageru):
    H -= nagerupower
    ab = np.delete(ab, nageru, 0)
    furu = np.argmax(ab[:,0])
    furupower = ab[furu,0]
    nageru = np.argmax(ab[:,1])
    nagerupower = ab[nageru,1]
    attack += 1
#振る
if H > 0:
    attack += math.ceil((H - nagerupower)/furupower)

#投げる
if H > 0:
    attack += 1
print(attack)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab = np.array(ab)
attack = 0

furu = np.argmax(ab[:,0])
furupower = ab[furu,0]
nageru = np.argmax(ab[:,1])
nagerupower = ab[nageru,1]

#投げる
while not(furupower >= nagerupower or furu == nageru):
    H -= nagerupower
    ab = np.delete(ab, nageru, 0)
    furu = np.argmax(ab[:,0])
    furupower = ab[furu,0]
    nageru = np.argmax(ab[:,1])
    nagerupower = ab[nageru,1]
    attack += 1
#振る
attack += math.ceil((H - nagerupower)/furupower)
#投げる
if H > 0:
    attack += 1
print(attack)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
ab = np.array(ab)
attack = 0

furu = np.argmax(ab[:,0])
furupower = ab[furu,0]
nageru = np.argmax(ab[:,1])
nagerupower = ab[nageru,1]

#投げる
while furupower < nagerupower and furu != nageru:
    H -= nagerupower
    ab = np.delete(ab, nageru, 0)
    furu = np.argmax(ab[:,0])
    furupower = ab[furu,0]
    nageru = np.argmax(ab[:,1])
    nagerupower = ab[nageru,1]
    attack += 1
#振る
attack += math.ceil((H - nagerupower)/furupower)
#投げる
if H > 0:
    attack += 1
print(attack)

Submission status: Wrong Answer

Solution code:
N, H = tuple(map(int, input().split(' ')))
katanas = [list(map(int, input().split(' '))) for _ in range(0, N)]

normaldmbs = list(map(lambda x: x[0], katanas))
max_normal_dmg = max(normaldmbs)

throwables = list(map(lambda x: x[1], filter(lambda x: (x[0] < x[1] and x[1] > max_normal_dmg), katanas)))
throwables.sort()

cnt = 0

for v in throwables:
    H -= v
    cnt += 1
    if H <= 0:
        break

if H > 0:
    if H % max_normal_dmg == 0:
        cnt += int(H / max_normal_dmg)
    else:
        cnt += int(H / max_normal_dmg) + 1


print(cnt)

Submission status: Wrong Answer

Solution code:
import math

N,H = map(int, input().split())
attack = []
for i in range(N):
    attack.append(list(map(int,input().split())))

a = [attack[i][0] for i in range(N)]
b = [attack[i][1] for i in range(N)]

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

sum = 0
nage = 0
for i in range(N):
    if a[0]>=b[i]:
        break
    nage += 1
    sum +=b[i]

print(math.ceil(nage + (H-sum)/a[0]))

Submission status: Wrong Answer

Solution code:
import math

N,H = map(int, input().split())
attack = []
for i in range(N):
    attack.append(list(map(int,input().split())))

a = [attack[i][0] for i in range(N)]
b = [attack[i][1] for i in range(N)]

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

sum = 0
nage = 0
for i in range(N):
    if a[0]>=b[i]:
        break
    nage += 1
    sum +=b[i]

print(math.ceil(nage + (H-sum)//a[0]))

Submission status: Wrong Answer

Solution code:
N, H = (int(i) for i in input().split())
A = []
B = []
for index in range(N):
	a, b = (int(i) for i in input().split())
	A.append(a)
	B.append(b)

arg_sorted = sorted(range(N), key=lambda k: B[k], reverse=True)

A_sorted = []
B_sorted = []
for i in arg_sorted:
	A_sorted.append(A[i])
	B_sorted.append(B[i])

S = []
for i in range(N):
	if i == 0:
		S.append(B_sorted[0])
	else:
		S.append(S[i-1]+B_sorted[i])

if S[N-1] < H:
	if N == 1:
		if H-S[0]>0:
			B_main = 1 + (H-S[0]-1) // A[0] + 1
		else:
			B_main = 1
	else:
		B_main = min((N-1) + (H-S[N-2]-1) // A[N-1] + 1, N + (H-S[N-1]-1) // A[N-1] + 1)
else:
	for i in range(N):
		if S[i] >= H:
			B_main = i + 1
			break

m = B_main

for i in range(N):
	if i == 0:
		if H-S[0]>0:
			A_mix = 1 + (H-S[0]-1) // A[0] + 1
		else:
			A_mix = 1
	elif H-S[i]>0:
		A_mix = (i+1) + (H-S[i]-1) // A[i] + 1
	else:
		A_mix = H
	m = min(A_mix, m)

print(m)

Submission status: Wrong Answer

Solution code:
N, H = (int(i) for i in input().split())
A = []
B = []
for index in range(N):
	a, b = (int(i) for i in input().split())
	A.append(a)
	B.append(b)

arg_sorted = sorted(range(N), key=lambda k: B[k], reverse=True)

A_sorted = []
B_sorted = []
for i in arg_sorted:
	A_sorted.append(A[i])
	B_sorted.append(B[i])

S = []
for i in range(N):
	if i == 0:
		S.append(B_sorted[0])
	else:
		S.append(S[i-1]+B_sorted[i])

if S[N-1] < H:
	if N == 1:
		if H-S[0]>0:
			B_main = 1 + (H-S[0]-1) // A[0] + 1
		else:
			B_main = 1
	else:
		B_main = (N-1) + (H-S[N-2]-1) // A[N-1] + 1
else:
	for i in range(N):
		if S[i] >= H:
			B_main = i + 1
			break

m = B_main

for i in range(N):
	if i == 0:
		if H-S[0]>0:
			A_mix = 1 + (H-S[0]-1) // A[0] + 1
		else:
			A_mix = 1
	elif H-S[i]>0:
		A_mix = (i+1) + (H-S[i]-1) // A[i] + 1
	else:
		A_mix = H
	m = min(A_mix, m)

print(m)

Submission status: Wrong Answer

Solution code:
import numpy as np

def katana(hp, katanas):
    katanas = np.array(katanas, 'i')
    max_slash = np.max(katanas[:, 0])
    throws = -np.sort(-katanas[:, 1])
    throws_index = np.where(throws > max_slash)[0]
    eff_throws = throws[throws_index]

    for i, v in enumerate(eff_throws):
        hp -= v
        if hp <= 0:
            print(i + 1)
            return

    print(len(eff_throws) + int(hp / max_slash + 0.9999999))

n, hp = map(int, input().split())
takanas = [list(map(int, input().split())) for _ in range(n)]
katana(hp, takanas)

Submission status: Wrong Answer

Solution code:

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

    A = []
    B = []

    d = 0
    for n in range(N):
        a, b = map(int, input().split())

        if a > d:
            d = a
        if b > d:
            B.append(b)

    C = []
    for b in B:
        if b > d:
            C.append(b)

    sorted(C, reverse=True)
    hp = H

    count = 0
    for c in C:
        hp -= c
        #C.remove(c)
        count += 1

        if hp <= 0:
            break

    if hp <= 0:
        print (count)

    else:
        s = hp//d
        if hp%d != 0:
            s += 1
        print (count+s)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Wrong Answer

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

    A = []
    B = []

    d = 0
    for n in range(N):
        a, b = map(int, input().split())

        if a > d:
            d = a
        if b > d:
            B.append(b)

    C = []
    for b in B:
        if b > d:
            C.append(b)


    count = len(C)
    hp = H-sum(C)

    if hp <= 0:
        print (count)

    else:
        s = hp//d
        if hp%d != 0:
            s += 1
        print (count+s)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Wrong Answer

Solution code:

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

    A = []
    B = []

    d = 0
    for n in range(N):
        a, b = map(int, input().split())

        if a > d:
            d = a

    C = []
    for b in B:
        if b > d:
            C.append(b)


    count = len(C)
    hp = H-sum(C)

    if hp <= 0:
        print (count)

    else:
        s = hp//d
        if hp%d != 0:
            s += 1
        print (count+s)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Wrong Answer

Solution code:

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

    A = []
    B = []

    d = 0
    for n in range(N):
        a, b = map(int, input().split())

        if a > d:
            d = a
        if b > d:
            B.append(b)

    C = []
    for b in B:
        if b > d:
            C.append(b)


    count = len(C)
    hp = H-sum(C)

    if hp <= 0:
        print (count)

    else:
        s = hp//d
        if hp%d != 0:
            s += 1
        print (count+s)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Wrong Answer

Solution code:
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
	atemp,btemp = map(int,input().split())
	a.append(atemp)
	b.append(btemp)
amax = max(a)
b.sort()
total = 0
counter = 0
i = n-1
while i >= 0 and b[i] >= amax:
	total += b[i]
	counter += 1
	i += -1
if (h-total)%amax == 0:
	counter = counter + (h-total)//amax
else:
	counter = counter + (h-total)//amax + 1
print(counter)

Submission status: Wrong Answer

Solution code:
import math

s=input()
s=s.split(' ')
honsu = int(s[0])
HP  = int(s[1])

kill=[]
throw=[]
tmp_throw=[]
for i in range(honsu):
	a,b = input().split(' ')
	kill.append(int(a))
	throw.append(int(b))
	tmp_throw.append(int(b))

#all throw?
tmp_throw.sort()
tmp_throw.reverse()
suma=0
for i,data in enumerate(tmp_throw):
	suma+=int(data)
	if suma >= HP:
		print(i+1)
		exit()

#
count=0
a_max=max(kill)
i = kill.index(a_max)
b_i = throw[i]
b_sum=0

for i in tmp_throw:
	if i >=a_max :
		count+=1
		b_sum += i
	else:
		break

HP = HP - b_sum
temp=0
count=count+ math.ceil(HP/a_max)

print(count)

Submission status: Wrong Answer

Solution code:
s=input()
s=s.split(' ')
honsu = int(s[0])
HP  = int(s[1])

kill=[]
throw=[]
tmp_throw=[]
for i in range(honsu):
	a,b = input().split(' ')
	kill.append(int(a))
	throw.append(int(b))
	tmp_throw.append(int(b))

#all throw?
tmp_throw.sort()
tmp_throw.reverse()
suma=0
for i,data in enumerate(tmp_throw):
	suma+=int(data)
	if suma >= HP:
		print(i+1)
		exit()

#
count=0
a_max=max(kill)
i = kill.index(a_max)
b_i = throw[i]
b_sum=0
throw.pop(i)

for i in throw:
	if i >=a_max :
		count+=1
		b_sum += i
	else:
		break

HP = HP - b_sum
temp=0
if HP >=0:
	temp = HP/a_max
	if temp == int(temp):
		temp=int(temp)
	else:
		temp=int(temp)+1
count += temp
print(count)

Submission status: Wrong Answer

Solution code:
s=input()
s=s.split(' ')
honsu = int(s[0])
HP  = int(s[1])

kill=[]
throw=[]
tmp_throw=[]
for i in range(honsu):
	a,b = input().split(' ')
	kill.append(int(a))
	throw.append(int(b))
	tmp_throw.append(int(b))

#all throw?
tmp_throw.sort()
tmp_throw.reverse()
suma=0
for i,data in enumerate(tmp_throw):
	suma+=int(data)
	if suma >= HP:
		print(i+1)
		exit()

#
count=0
a_max=max(kill)
i = kill.index(a_max)
b_i = throw[i]
b_sum=0
tmp_throw.pop(i)

for i in tmp_throw:
	if i >=a_max :
		count+=1
		b_sum += i
	else:
		break

HP = HP - b_sum
temp=0
if HP >=0:
	temp = HP/a_max
	if temp == int(temp):
		temp=int(temp)
	else:
		temp=int(temp)+1
count += temp
print(count)

Submission status: Wrong Answer

Solution code:
s=input()
s=s.split(' ')
honsu = int(s[0])
HP  = int(s[1])

kill=[]
throw=[]
tmp_throw=[]
for i in range(honsu):
	a,b = input().split(' ')
	kill.append(int(a))
	throw.append(int(b))
	tmp_throw.append(int(b))

#all throw?
tmp_throw.sort()
tmp_throw.reverse()
suma=0
for i,data in enumerate(tmp_throw):
	suma+=int(data)
	if suma >= HP:
		print(i+1)
		exit()

#
count=0
a_max=max(kill)
i = kill.index(a_max)
b_i = throw[i]
b_sum=0

for i in tmp_throw:
	if i >=b_i :
		count+=1
		b_sum += i
	else:
		break

HP = HP - b_sum
temp=0
if HP >=0:
	temp = HP/a_max
	if temp == int(temp):
		temp=int(temp)
	else:
		temp=int(temp)+1
count += temp
print(count)

Submission status: Wrong Answer

Solution code:
s=input()
s=s.split(' ')
honsu = int(s[0])
HP  = int(s[1])

kill=[]
throw=[]
tmp_throw=[]
for i in range(honsu):
	a,b = input().split(' ')
	kill.append(int(a))
	throw.append(int(b))
	tmp_throw.append(int(b))

#all throw?
tmp_throw.sort()
tmp_throw.reverse()
suma=0
for i,data in enumerate(tmp_throw):
	suma+=int(data)
	if suma >= HP:
		print(i+1)
		exit()

#
count=0
a_max=max(kill)
i = kill.index(a_max)
b_i = throw[i]
b_sum=0

for i in tmp_throw:
	if i >a_max :
		count+=1
		b_sum += i
	else:
		break

HP = HP - b_sum
temp=0
if HP >=0:
	temp = HP/a_max
	if temp == int(temp):
		temp=int(temp)
	else:
		temp=int(temp)+1
count += temp
print(count)