Skip to content

Instantly share code, notes, and snippets.

@danny8376
Created December 4, 2014 17:51
Show Gist options
  • Save danny8376/d64e9bc69fd3364f1776 to your computer and use it in GitHub Desktop.
Save danny8376/d64e9bc69fd3364f1776 to your computer and use it in GitHub Desktop.
# 自分の得意な言語で
# Let's チャレンジ!!
# Normal way
=begin
sum = 0
# first input is the count of lines
gets.to_i.times do
required, now, price = gets.split(" ").map{|i| i.to_i}
# make it no smaller than 0
sum += [required - now, 0].max * price
end
puts sum
=end
# Rubyは怖いです
puts gets.to_i.times.map {
required, now, price = gets.split(" ").map{|i| i.to_i}
[required - now, 0].max * price
}.inject(&:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment