Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Codeforces #412 Div2
n = gets.chomp.to_i
ratings = []
n.times do
a, b = gets.chomp.split(" ").map(&:to_i)
if a != b then
puts "rated"
exit
else
ratings << b
end
end
(n-1).times do |i|
if ratings[i] < ratings[i+1] then
puts "unrated"
exit
end
end
puts "maybe"
p, x, y = gets.chomp.split(" ").map(&:to_i)
def tshirt(s)
ret = []
i = (s / 50) % 475
25.times do
i = (i * 96 + 42) % 475
ret << (26 + i)
end
return ret
end
if x > y then
d = ((x - y) / 50.0).floor
xx = x - (d * 50)
while true
if tshirt(xx).include?(p) then
puts 0
exit
elsif xx >= x then
break
end
xx += 50
end
end
d = ([0, y - x].max / 50.0).ceil
x += (d * 50)
while true
break if tshirt(x).include?(p)
x += 50
d += 1
end
if d.even?
puts d / 2
else
puts d / 2 + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment