Created
December 20, 2014 19:02
-
-
Save ser1zw/8701ce2d17d6c454170b to your computer and use it in GitHub Desktop.
paiza online hackathon vol.4 Lite https://paiza.jp/poh/enkoi
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
# https://paiza.jp/poh/enkoi-second/a19c27e5 | |
s = 0 | |
gets | |
s += $_.to_i while gets | |
puts s |
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
# https://paiza.jp/poh/enkoi-third/fa58b3c7 | |
total = 0 | |
gets | |
while gets | |
t, s, pr = $_.split(/\s/).map(&:to_i) | |
total += (t - s) * pr if t > s | |
end | |
puts total |
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
# https://paiza.jp/poh/enkoi-ending/4cdd6477 | |
t, _ = gets.split(/\s/).map(&:to_i) | |
a = [] | |
a << $_.to_i while gets | |
s = [a[0]] | |
1.step(a.size - 1) { |i| | |
s[i] = s[i - 1] + a[i] | |
} | |
max = s[t - 1] | |
t.step(a.size - 1) { |i| | |
x = s[i] - s[i - t] | |
max = x if max < x | |
} | |
puts max |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment