Skip to content

Instantly share code, notes, and snippets.

@fdutey
Last active November 7, 2017 03:22
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 fdutey/ae2666cc4ab00a544e9d1bb585d74c93 to your computer and use it in GitHub Desktop.
Save fdutey/ae2666cc4ab00a544e9d1bb585d74c93 to your computer and use it in GitHub Desktop.
def parse_arg(arg)
a, b, q = arg.split(' ').map(&:to_i)
[Range.new(a, b), q]
end
inputs = []
while arg = STDIN.gets
inputs << parse_arg(arg)
end
# Drop the first line
input.shift
acc = Hash.new { |h, k|, h[k] = [] }
inputs.each do |r, q|
r.each { |i| acc[i] << q }
end
acc.values.map(&:sum).max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment