Last active
November 7, 2017 03:22
-
-
Save fdutey/ae2666cc4ab00a544e9d1bb585d74c93 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
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