Created
December 4, 2014 17:51
-
-
Save danny8376/d64e9bc69fd3364f1776 to your computer and use it in GitHub Desktop.
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
# 自分の得意な言語で | |
# 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