Last active
August 29, 2015 14:10
-
-
Save takano32/9d4b03ca5fd0c8e2a92c 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
#!/usr/bin/env ruby | |
input_lines = ARGF | |
first = true | |
sum = 0 | |
input_lines.each_line do |line| | |
if first then | |
first = false | |
next | |
end | |
t, s, p = (line.split ' ').map {|s| s.to_i} | |
if not t <= s then | |
sum += (t - s) * p | |
end | |
end | |
puts sum |
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
#!/usr/bin/env ruby | |
# | |
input_lines = ARGF.read | |
t = 0 | |
n = 0 | |
m = [] | |
first = true | |
input_lines.each_line do |line| | |
if first then | |
first = false | |
t, n = (line.split ' ').map {|s| s.to_i} | |
next | |
end | |
m << line.strip.to_i | |
end | |
max = 0 | |
m.each_cons(t) do |ms| | |
v = ms.inject(:+) | |
if max < v then | |
max = v | |
end | |
end | |
puts max | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment