Create a gist now

Instantly share code, notes, and snippets.

Educational Codeforces Round 6
x1, y1 = gets.chomp.split(" ").map(&:to_i)
x2, y2 = gets.chomp.split(" ").map(&:to_i)
dx = (x1 - x2).abs()
dy = (y1 - y2).abs()
puts [dx, dy].max
a, b = gets.chomp.split(" ").map(&:to_i)
val = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
res = 0
(a..b).each do |n|
while n > 0
res += val[n%10]
n /= 10
end
end
puts res
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new([])
res = []
a.each_with_index do |i, j|
h[i] += [j + 1]
if h[i].length() == 2 then
res << h[i]
h = Hash.new([])
end
end
if res.empty? then
puts -1
else
puts res.length()
res.last[1] = n
tmp = 1
res.each do |r|
puts [[r[0], tmp].min, r[1]].join(" ")
tmp = r[1] + 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment