Submission #2855577


Source Code Expand

N,H = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
as = []
bs = []
N.times {
  a,b = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }  
  as << a
  bs << b
}

MA = as.max
T = (bs.select{ |b| b > MA } || []).sort_by{ |b| -b }
TT = T.inject(:+) || 0

if H > TT
  puts T.size + ((H - TT - 1) / MA) + 1
  exit
end

h = 0
T.each_with_index { |b,i|
  h += b
  if h >= H
    puts i+1
    break
  end
}




Submission Info

Submission Time
Task D - Katana Thrower
User Corvvs
Language Ruby (2.3.3)
Score 400
Code Size 429 Byte
Status AC
Exec Time 239 ms
Memory 7432 KB

Compile Error

./Main.rb:5: warning: shadowing outer local variable - a

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 7 ms 1788 KB
a02 AC 7 ms 1788 KB
a03 AC 7 ms 1788 KB
a04 AC 7 ms 1788 KB
b05 AC 7 ms 1788 KB
b06 AC 162 ms 3468 KB
b07 AC 7 ms 1788 KB
b08 AC 160 ms 3468 KB
b09 AC 7 ms 1788 KB
b10 AC 7 ms 1788 KB
b11 AC 7 ms 1788 KB
b12 AC 7 ms 1788 KB
b13 AC 193 ms 6536 KB
b14 AC 196 ms 6664 KB
b15 AC 140 ms 3468 KB
b16 AC 140 ms 3468 KB
b17 AC 152 ms 3468 KB
b18 AC 146 ms 3468 KB
b19 AC 223 ms 7432 KB
b20 AC 209 ms 6408 KB
b21 AC 233 ms 7176 KB
b22 AC 239 ms 7432 KB
b23 AC 7 ms 1788 KB
b24 AC 11 ms 1912 KB