Skip to content

Instantly share code, notes, and snippets.

@ser1zw
Created December 20, 2014 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ser1zw/8701ce2d17d6c454170b to your computer and use it in GitHub Desktop.
Save ser1zw/8701ce2d17d6c454170b to your computer and use it in GitHub Desktop.
paiza online hackathon vol.4 Lite https://paiza.jp/poh/enkoi
# https://paiza.jp/poh/enkoi-second/a19c27e5
s = 0
gets
s += $_.to_i while gets
puts s
# 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
# 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