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:
from itertools import accumulate
from bisect import bisect_left
from math import ceil

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

# A昇順、B降順にソート
AB.sort(key=lambda x: (x[0], -x[1]))

# 最後の刀を装備する
equip = AB.pop()

# a_max < b なる刀を集める
b_list = [0]
for a,b in AB:
    if b > equip[0]:
        b_list.append(b)
        
b_list.sort()
b_list_cum = list(accumulate(b_list))

ans = 0
# hpがb_list_cum[-1]以下なら、刀投げで終わる
if H <= b_list_cum[-1]:
    ans = bisect_left(b_list_cum,H)
    print(ans)

# 違えば、まずはb>=a_maxなる刀を全部投げ、equipでhp<=bになるまで攻撃し、
# 最後の1手で刀を投げる
else:
    ans = len(b_list_cum)-1
    res = H - b_list_cum[-1]
    a_attack = max(0, ceil((res-equip[1]) / equip[0]))
    
    # aで攻撃した分と、最後の1手の刀投げの分を足す
    ans += (a_attack + 1)
    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from bisect import bisect_left
from math import ceil

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

# A昇順、B降順にソート
AB.sort(key=lambda x: (x[0], -x[1]))

# 最後の刀を装備する
equip = AB.pop()

# a_max <= b なる刀を集める
b_list = [0]
for a,b in AB:
    if b >= equip[0]:
        b_list.append(b)
        
b_list.sort()
b_list_cum = list(accumulate(b_list))

ans = 0
# hpがb_list_cum[-1]以下なら、刀投げで終わる
if H <= b_list_cum[-1]:
    ans = bisect_left(b_list_cum,H)
    print(ans)

# 違えば、まずはb>=a_maxなる刀を全部投げ、equipでhp<=bになるまで攻撃し、
# 最後の1手で刀を投げる
else:
    ans = len(b_list_cum)-1
    res = H - b_list_cum[-1]
    a_attack = max(0, ceil((res-equip[1]) / equip[0]))
    
    # aで攻撃した分と、最後の1手の刀投げの分を足す
    ans += (a_attack + 1)
    print(ans)

Submission status: Wrong Answer

Solution code:
N,H=map(int, input().split())
count=0
a=[];b=[]
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai);b.append(bi)
amax=max(a)
for x in b:
    if x>=amax and H>0: H-=x;count+=1
count-=(-H//amax)
print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, H = li_input()
    S = [li_input() for _ in range(N)]

    ans = 0

    maxcut = -1
    for s in S:
        if s[0] > maxcut:
            maxcut = s[0]

    for s in S:
        if s[1] > maxcut:
            ans += 1
            H -= s[1]

            if H <= 0:
                break

    if H > 0:
        ans += H // maxcut

        if H % maxcut != 0:
            ans += 1

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, H = li_input()
    S = [li_input() for _ in range(N)]

    ans = 0

    maxcut = -1
    for s in S:
        if s[0] > maxcut:
            maxcut = s[0]

    for s in S:
        if s[1] > maxcut:
            ans += 1
            H -= s[1]

            if H <= 0:
                break

    if H > 0:
        ans += math.ceil(H / maxcut)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, H = li_input()
    S = [li_input() for _ in range(N)]

    ans = 0

    maxcut = -1
    for s in S:
        if s[0] > maxcut:
            maxcut = s[0]

    for s in S:
        if s[1] > maxcut:
            ans += 1
            H -= s[1]

    ans += math.ceil(H / maxcut)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import bisect
n,h = map(int,input().split())
v=[list(map(int,input().split())) for i in range(n)]

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

a = []
b = []
for i in range(n):
    a.append(v[i][0])
    b.append(v[i][1])

m = max(a)    
k = bisect.bisect_left(b,m)
b.append(0)

#print(k,m)
#print(sum(b[k::]))

hj = (h-sum(b[k::]))
if hj%m == 0:
    i = 0
else:
    i = 1

if hj <= 0:
    for i in range(n):
        h  = h-b[n-1-i]
        if h <= 0:
            print(i + 1)
else:
    print(hj//m + i + n - k)

Submission status: Wrong Answer

Solution code:
import bisect
n,h = map(int,input().split())
v=[list(map(int,input().split())) for i in range(n)]

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

a = []
b = []
for i in range(n):
    a.append(v[i][0])
    b.append(v[i][1])

m = max(a)    
k = bisect.bisect_left(b,m)
b.append(0)

#print(k,m)
#print(sum(b[k::]))
hj = (h-sum(b[k::]))
if hj%m == 0:
    i = 0
else:
    i = 1
print(hj//m + i + n - k)

Submission status: Wrong Answer

Solution code:
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma and H > 0:
  i += 1
  if i == N:
    Mb = 0
  else:
    H -= Mb
    Mb = B[i]
if H <= 0:
  print(i)
else:
  print(i+int(-(-H//Ma)))

Submission status: Wrong Answer

Solution code:
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma:
  i += 1
  if i == N:
    Mb = 0
  else:
    Mb = B[i]
B = B[:i]
H -= sum(B)
j = max(0,int(-(-H//Ma)))
print(i+j)

Submission status: Wrong Answer

Solution code:
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma:
  i += 1
  if i == N:
    Mb = 0
    B = B[:i]
  else:
    Mb = B[i]
H -= sum(B)
print(i+int(-(-H//Ma)))

Submission status: Wrong Answer

Solution code:
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
C = 0
i = 0
while i < len(B) and B[i] > Ma:
  i += 1
H -= sum(B[:i])
print(i+int(-(-H//Ma)))

Submission status: Wrong Answer

Solution code:
# https://beta.atcoder.jp/contests/abc085/tasks/abc085_d

def solve():
    n, m = map(int, input().split())
    # n, m = 4, 1000000000
    # swing, throw = [1, 1, 1, 1], [1, 10000000, 99999999, 30000000]
    swing, throw = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        swing.append(a)
        throw.append(b)
    swing = sorted(swing)
    throw = sorted(throw)
    max_swing = swing[-1]
    will_throw = [x for x in throw if x > max_swing]

    all_damage = sum(will_throw)
    answer = len(will_throw)
    if all_damage > m:
        for damage in will_throw:
            if all_damage - damage < m:
                print(answer)
            else:
                all_damage -= damage
                answer -= 1
    else:
        print(answer + ((m - all_damage) + (max_swing - 1)) // max_swing)

solve()

Submission status: Wrong Answer

Solution code:
# https://beta.atcoder.jp/contests/abc085/tasks/abc085_d

def solve():
    # n, m = map(int, input().split())
    n, m = 4, 1000000000
    swing, throw = [1, 1, 1, 1], [1, 10000000, 99999999, 30000000]
    # swing, throw = [], []
    # for _ in range(n):
    #     a, b = map(int, input().split())
    #     swing.append(a)
    #     throw.append(b)
    swing = sorted(swing)
    throw = sorted(throw)
    max_swing = swing[-1]
    will_throw = [x for x in throw if x > max_swing]

    all_damage = sum(will_throw)
    answer = len(will_throw)
    if all_damage > m:
        for damage in will_throw:
            if all_damage - damage < m:
                print(answer)
            else:
                all_damage -= damage
                answer -= 1
    else:
        print(answer + ((m - all_damage) + (max_swing - 1)) // max_swing)

solve()

Submission status: Wrong Answer

Solution code:
import math
N, HP = map(int, input().split())
 
hit = 0
throw = []
for i in range(N):
    h, t = map(int, input().split())
    if h > hit:
        hit = h
    throw.append(t)
 
throw.sort()
 
 
ans = 0
for t in throw[::-1]:
    if t < hit:
        break
    else:
        ans += 1
        HP -= t
        if HP <= 0:
            break
if HP > 0:
  ans += math.ceil(HP // hit)
 
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, HP = map(int, input().split())

hit = 0
throw = []
for i in range(N):
    h, t = map(int, input().split())
    if h > hit:
        hit = h
    throw.append(t)

throw.sort()


ans = 0
for t in throw[::-1]:
    if t < hit:
        break
    else:
        ans += 1
        HP -= t
        if HP <= 0:
            break

ans += math.ceil(HP / hit)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, HP = map(int, input().split())

hit = 0
throw = []
for i in range(N):
    h, t = map(int, input().split())
    if h > hit:
        hit = h
    throw.append(t)

throw.sort()


ans = 0
for t in throw[::-1]:
    if t < hit:
        break
    else:
        ans += 1
        HP -= t
        if HP <= 0:
            break

ans += math.ceil((HP * 100.0) / (hit)) /100
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, HP = map(int, input().split())

hit = 0
throw = []
for i in range(N):
    h, t = map(int, input().split())
    if h > hit:
        hit = h
    throw.append(t)

throw.sort()


ans = 0
for t in throw[::-1]:
    if t < hit:
        break
    else:
        ans += 1
        HP -= t
        if HP <= 0:
            break

ans += math.ceil((HP * 100.0) / (hit * 100.0))
print(ans)

Submission status: Wrong Answer

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

hit = 0
throw = []
for i in range(N):
    h, t = map(int, input().split())
    if h > hit:
        hit = h
    throw.append(t)

throw.sort()


ans = 0
for t in throw[::-1]:
    if t < hit:
        break
    else:
        ans += 1
        HP -= t
        if HP <= 0:
            break

ans += (HP * 100) // (hit * 100)
print(ans)

Submission status: Wrong Answer

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

hit = []
throw = []
for i in range(N):
    h, t = map(int, input().split())
    hit.append(h)
    throw.append(t)

h = max(hit)
throw.sort()
throw.reverse()

ans = 0
for t in throw:
    if t < h:
        break
    else:
        ans += 1
        HP -= t
        print("throw", HP, h)
        if HP <= 0:
            break

while HP > 0:
    ans += 1
    HP -= h
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from itertools import accumulate

n, h = map(int, input().split())
xs = [[int(x) for x in input().split()] for _ in range(n)]

a = max(x[0] for x in xs)
ys = sorted(-x[1] for x in xs)
zs = [0] + list(accumulate(-y for y in ys))

i = bisect_left(ys, -a)
j = bisect_right(zs, h)

b_count = min(i, j, n)
remaining = max(h - zs[b_count], 0)
a_count = (remaining + a - 1) // a
print(b_count + a_count)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from itertools import accumulate

n, h = map(int, input().split())
xs = [[int(x) for x in input().split()] for _ in range(n)]

a = max(x[0] for x in xs)
ys = sorted(-x[1] for x in xs)
zs = [0] + list(accumulate(-y for y in ys))

i = bisect_left(ys, -a)
j = bisect_right(zs, h)

b_count = min(i, j, n)
remaining = h - zs[b_count]
a_count = (remaining + a - 1) // a
print(b_count + a_count)

Submission status: Wrong Answer

Solution code:
class Sword:
    def __init__(self, id, swing, throw):
        self.id = id
        self.swing = swing
        self.throw = throw


def main():
    n, h = map(int, input().split())

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

    s1, s2 = s[:], s[:]
    s1.sort(key=lambda sword: sword.swing, reverse=True)
    s2.sort(key=lambda sword: sword.throw, reverse=True)

    idx, c = 0, 0
    while idx < n and s2[idx].throw >= s1[0].swing and h > 0:
        h -= s2[idx].throw
        c += 1
        idx += 1

    c += (h+s1[0].swing-1) // s1[0].swing
    print(c)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
N,H = map(int,input().split())
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
y = sorted(y)
xm = max(x)
d = 0
a = 1
while a:
  if xm > y[-a]: 
    a= a-1
    break
  d += y[-a]
  if d>H:
    break
  if a == N: break
  a +=1
if d> H:
  print(a)
else:
  e = math.ceil((H-d)/xm)
  print(a+e)

Submission status: Wrong Answer

Solution code:
import math
N, H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

a_max = max(a for a,b in AB)
B = [b for a,b in AB]
B.sort(reverse=True)

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

#ans += HP//a_max+ bool(HP%a_max)
ans += math.ceil(HP/a_max)
print(ans)

Submission status: Wrong Answer

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

a_max = max(a for a,b in AB)
B = [b for a,b in AB]
B.sort(reverse=True)

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

ans += HP//a_max+ bool(HP%a_max)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,h = map(int,raw_input().split())

arra = []
arrb = []


for i in range(n):
	a , b = map(int,raw_input().split())
	arra.append(a)
	arrb.append(b)

arrb.sort()

l = len(arrb) - 1 
m = max(arra)
count = 0
while arrb[l] > m and -1 < l:
	h = max(0,h-arrb[l])
	l -= 1
	count += 1

print count + -(h*-1 // m)

Submission status: Wrong Answer

Solution code:
import math
n,h = map(int,raw_input().split())

arra = []
arrb = []


for i in range(n):
	a , b = map(int,raw_input().split())
	arra.append(a)
	arrb.append(b)

arrb.sort()

l = len(arrb) - 1 
m = max(arra)
count = 0
while arrb[l] > m and -1 < l:
	h = max(0,h-arrb[l])
	l -= 1
	count += 1

print count + int(math.ceil(h/m))

Submission status: Wrong Answer

Solution code:
import math
n,h = map(int,raw_input().split())

arra = []
arrb = []


for i in range(n):
	a , b = map(int,raw_input().split())
	arra.append(a)
	arrb.append(b)

arrb.sort()

l = len(arrb) - 1 
m = max(arra)
count = 0
while arrb[l] > m and 0 < l:
	h = max(0,h-arrb[l])
	l -= 1
	count += 1

print count + int(math.ceil(h/m))

Submission status: Wrong Answer

Solution code:
import math
n,h = map(int,raw_input().split())

arra = []
arrb = []


for i in range(n):
	a , b = map(int,raw_input().split())
	arra.append(a)
	arrb.append(b)

arrb.sort()

l = len(arrb) - 1 
m = max(arra)
count = 0
while arrb[l] > m and 0 < l:
	h -= arrb[l]
	l -= 1
	count += 1

print count + int(math.ceil(h/m))

Submission status: Wrong Answer

Solution code:
import math

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

a.sort()
a.reverse()
b.sort()
b.reverse()
ptr = 0
cnt = 0

while(ptr < N and a[0] <= b[ptr]):
	H -= b[ptr]
	ptr+=1
	cnt+=1
	if H <= 0: break

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

Submission status: Wrong Answer

Solution code:
import math

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

a.sort()
a.reverse()
b.sort()
b.reverse()
ptr = 0
cnt = 0

while(ptr < N and a[0] <= b[ptr]):
	H -= b[ptr]
	ptr+=1
	cnt+=1

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""



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

A_max = 0
D_seq = []

for i in range(N):
    A, D = map(int, input().split())
    if A>A_max:
        A_max = A
    D_seq.append(D)

D_sum = 0
D_count = 0
D_seq.sort()

for i in range(N):
    if D_seq[i] > A_max and D_sum < H:
        D_sum += D_seq[i]
        D_count += 1

A_sum = H-D_sum

if A_sum > 0:
    if A_sum%A_max == 0:
        print(A_sum//A_max + D_count)
    else:
        print(A_sum//A_max + D_count+1)
else:
    print(D_count)

Submission status: Wrong Answer

Solution code:
a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  #max weild
ms=[]  #number of max weild
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)

br=100000000000 #min throw amoung max weild
for j in range(1,a+1):
  if ab[j][0]==ma:
    ms.append(j)
    br=min(br,ab[j][1])

index=0  #index of ideal weild katana

for j in range(1,a+1):
  if ab[j][1]==br:
    index=j

count=0



for i in range(1,a+1):
  if i!=index:


    if ab[i][1]>=ma and b>0 and a!=1:
      count+=1
      b-=ab[i][1]
  else:
    count+=1
    b-=br


if a!=1:
  count+=1
  b-=br

def cel(x):
  if x==int(x):
    return x
  else:
    return int(x)+1



if b>0:
  count+=(cel(b/ma))


print(int(count))

Submission status: Wrong Answer

Solution code:
a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  #max weild
ms=[]  #number of max weild
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)

br=100000000000 #min throw amoung max weild
for j in range(1,a+1):
  if ab[j][0]==ma:
    ms.append(j)
    br=min(br,ab[j][1])

index=0  #index of ideal weild katana

for j in range(1,a+1):
  if ab[j][1]==br:
    index=j

count=0
for i in range(1,a+1):
  if i!=index and ab[i][1]>=ma and b>0 and a!=1:
    count+=1
    b-=ab[i][1]
  else:
    count+=1
    b-=br



def cel(x):
  if x==int(x):
    return x
  else:
    return int(x)+1



if b>0:
  count+=(cel(b/ma))




print(int(count))

Submission status: Wrong Answer

Solution code:
a,b=[int(x) for x in str(input()).split()]
ab=[[0,0]]

ma=0  #max weild
ms=[]  #number of max weild
for j in range(1,a+1):
  A=[int(x) for x in str(input()).split()]
  ma=max(ma,A[0])
  ab.append(A)

br=100000000000 #min throw amoung max weild
for j in range(1,a+1):
  if ab[j][0]==ma:
    ms.append(j)
    br=min(br,ab[j][1])

index=0  #index of ideal weild katana

for j in range(1,a+1):
  if ab[j][1]==br:
    index=j

count=0
for i in range(1,a+1):
  if ab[i][1]!=br and ab[i][1]>=ma and b>0 and a!=1:
    count+=1
    b-=ab[i][1]
  else:
    count+=1
    b-=br



def cel(x):
  if x==int(x):
    return x
  else:
    return int(x)+1



if b>0:
  count+=(cel(b/ma))




print(int(count))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 03:01:30 2018

@author: ashida
"""

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

A_max = 0
D_seq = []

for i in range(N):
    A, D = map(int, input().split())
    if A>A_max:
        A_max = A
    D_seq.append(D)

D_sum = 0
D_count = 0

for i in range(N):
    if D_seq[i] > A_max and D_sum < H:
        D_sum += D_seq[i]
        D_count += 1

A_sum = H-D_sum

if A_sum > 0:
    if A_sum%A_max == 0:
        print(A_sum//A_max + D_count)
    else:
        print(A_sum//A_max + D_count+1)
else:
    print(D_count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 03:01:30 2018

@author: ashida
"""

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

A_max = 0
D_seq = []

for i in range(N):
    A, D = map(int, input().split())
    if A>A_max:
        A_max = A
    D_seq.append(D)

D_sum = 0
D_count = 0

for i in range(N):
    if D_seq[i] > A_max and D_sum < H:
        D_sum += D_seq[i]
        D_count += 1

A_sum = H-D_sum

if A_sum%A_max == 0:
    print(A_sum//A_max + D_count)
else:
    print(A_sum//A_max + D_count+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 03:01:30 2018

@author: ashida
"""

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

A_max = 0
D_seq = []

for i in range(N):
    A, D = map(int, input().split())
    if A>A_max:
        A_max = A
    D_seq.append(D)

D_sum = 0
D_count = 0

for i in range(N):
    if D_seq[i] > A_max:
        D_sum += D_seq[i]
        D_count += 1

A_sum = H-D_sum

if A_sum%A_max == 0:
    print(A_sum//A_max + D_count)
else:
    print(A_sum//A_max + D_count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n,H=map(int,input().split())
S=[]
for i in range(n):
    
    S.append(list(map(int,input().split())))
    
a=[]
b=[]
for i in range(n):
    a.append(S[i][0])
    
for i in range(n):
    if(max(a)<S[i][1]):
        b.append(S[i][1])

b.sort()
b.reverse()
k=0
count=0
while H>0:
    if len(b)>k:
        H-=b[k]
        k+=1
        count+=1
    else:
        
        count+=H//max(a)
        H=0

print(count)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right,bisect_left
import sys
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
B.sort()
ama=max(A)
x = bisect_right(B,ama)
ans = 0
if x ==N:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
    print(ans)
    sys.exit()
for i in range(x,N):
    if H<=0:
        print(ans)
        sys.exit()
    elif H>0:
        H-=B[i]
        ans +=1
if H>0:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right,bisect_left
import sys
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
B.sort()
ama=max(A)
x = bisect_right(B,ama)
ans = 0
if x ==N:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
    print(ans)
    sys.exit()
for i in range(x,N):
    if H<=0:
        print(ans)
        sys.exit()
    if H>0:
        H-=B[i]
        ans +=1
if H>0:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right,bisect_left
import sys
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
B.sort()
ama=max(A)
x = bisect_right(B,ama)
ans = 0
if x ==N:
    ans = H//ama +1
    print(ans)
    sys.exit()
for i in range(x,N):
    if H<=0:
        print(ans)
        sys.exit()
    if H>0:
        H-=B[i]
        ans +=1
if H>0:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama +1
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right,bisect_left
import sys
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
B.sort()
ama=max(A)
x = bisect_right(B,ama)
ans = 0
if x ==N:
    ans = H//ama +1
    print(ans)
    sys.exit()
for i in range(x,N):
    if H<=0:
        print(ans)
        sys.exit()
    if H>0:
        H-=B[i]
        ans +=1
if H>0:
    if H%ama ==0:
        ans += H//ama 
    else:
        ans += H//ama 
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, H = map(int, input().split())
katana = {i: list(map(int, input().split())) for i in range(N)}

# 振り攻撃最大
max_i, (max_a, max_b) = max(katana.items(), key=lambda x: x[1][0])

ans = 0
for i, (_, b) in sorted(katana.items(), key=lambda x: x[1][1], reverse=True):
    if i == max_i:
        continue
    if H <= max_b:
        break
    if b < max_a:
        break
    H -= b
    ans += 1

ans += 1
H -= max_b
if H > 0:
    ans += math.ceil(H / max_a)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())
    a = [0 for _ in range(N)]
    b = [0 for _ in range(N)]
    for i in range(N):
        a[i], b[i] = map(int, input().split())

    A = max(a)
    count = 0
    for i in range(N):
        if b[i]>A:
            count += 1
            H = H - b[i]
            if H <= 0:
                return count
    
    if H%A==0:
        return count + H//A
    else:
        return count + H//A + 1

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

Submission status: Wrong Answer

Solution code:
def main():
    N, H = map(int, input().split())
    a = [0 for _ in range(N)]
    b = [0 for _ in range(N)]
    for i in range(N):
        a[i], b[i] = map(int, input().split())

    A = max(a)
    count = 0
    for i in range(N):
        if b[i]>A:
            count += 1
            H = H - b[i]
    
    if H%A==0:
        return count + H//A
    else:
        return count + H//A + 1

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

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)
filtered = [b_i for b_i in B if b_i > max_a]
sum_b = sum(filtered)
if sum_b <= H:
    print(-(-(H - sum_b) // max_a) + len(filtered))
else:
    filtered.sort()
    filtered.reverse()
    s = 0
    for i in range(len(filtered)):
        s += filtered[i]
        if s > H:
            print(i + 1)
            break

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)
filtered = [b_i for b_i in B if b_i > max_a]
sum_b = sum(filtered)
print(-(-(H - sum_b) // max_a) + len(filtered))

Submission status: Wrong Answer

Solution code:
# https://abc085.contest.atcoder.jp/tasks/abc085_d

from operator import itemgetter
from itertools import chain

def trans(lst):
    return ((int(lst[0]), False), (int(lst[1]), True))

a,b = map(int, input().split())
data = list(chain.from_iterable([trans(input().split()) for _ in range(a)]))
data.sort(key=itemgetter(0), reverse=True)

count = 0
while b > 0:
    if data[0][1]:
        b -= data.pop(0)[0]
        count += 1
        continue
    else:
        count += int(b/data[0][0])
        break
print(count)

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB]
A.sort()
B = [i[1] for i in AB]
B.sort()

furudamage = A[-1]
count= 0
while len(B) > 0:
    nagedamage = B.pop()
    if nagedamage > furudamage:
        H -= nagedamage
        count += 1
        if H <= 0:
            print(count)
            break
    else:
        break
if H > 0:
    count += round(H/furudamage)
    print(count)

Submission status: Wrong Answer

Solution code:

N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB]
A.sort()
B = [i[1] for i in AB]
B.sort()

count= 0
while len(B) > 0:
    damage = B.pop()
    H -= damage
    count += 1
    if H <= 0:
        print(count)
        break


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

Submission status: Wrong Answer

Solution code:
N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB]
A.sort()
B = [i[1] for i in AB]
B.sort()

count= 0
while len(B) > 0:
    damage = B.pop()
    H -= damage
    count += 1
    if H <= 0:
        print(count)

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

Submission status: Wrong Answer

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

arr = [[0 for column in range(2)] for row in range(n)]
for i in range(n):
	line = map(int,raw_input().split())
	arr[i][0] = line[0]
	arr[i][1] = line[1]

max = 0
for i in range(n):
	if arr[i][0] > max:
		max = arr[i][0]

list = []
list.append(0)

for i in range(n):
	if arr[i][1] > max:
		list.append(arr[i][1])

list.sort()
list.reverse()


count = 0
sumofthrow = sum(list)

count += -(-(h-sumofthrow)//max )
h -= max * -(-(h-sumofthrow)//max )



while h > 0 :
	h -= list.pop(0)
	count += 1

print count

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
        if H<=0:
            break
    else:
        break
print(ct+((H//am)+int(H%am!=0)) if H>0 else 0)

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
while H>0:
    H-=am
    ct+=1
print(ct)