Created
October 14, 2018 06:06
-
-
Save whatalnk/e43931654dafcdd565473920d4788018 to your computer and use it in GitHub Desktop.
AtCoder ABC #085 D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, h = gets.chomp.split(" ").map(&:to_i) | |
a = [] | |
b = [] | |
n.times do | |
a_, b_ = gets.chomp.split(" ").map(&:to_i) | |
a << a_ | |
b << b_ | |
end | |
amax = a.max | |
b.sort! | |
ans = 0 | |
(n-1).downto(0) do |i| | |
if h <= 0 | |
puts ans | |
exit | |
end | |
if b[i] > amax | |
h -= b[i] | |
ans += 1 | |
end | |
end | |
ans += h / amax | |
if h % amax == 0 | |
puts ans | |
else | |
puts ans + 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment