Create a gist now

Instantly share code, notes, and snippets.

ARC#001
n = gets.chomp.to_i
c = gets.chomp.split("").map(&:to_i)
ans = [1,2,3,4]
cnt = []
ans.each do |a|
cnt << c.count(a)
end
print cnt.max, " ", cnt.min, "\n"
a, b = gets.chomp.split(" ").map(&:to_i)
temperature = [[a, 0]]
button = [1, -1, 5, -5, 10, -10]
while !temperature.empty?
c = temperature.shift
break if c[0] == b
button.each do |d|
if (c[0]+d - b).abs < (c[0] - b).abs then
temperature << [c[0]+d, c[1]+1]
end
end
end
puts c[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment