Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created May 7, 2017 23:34
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 whatalnk/67147ada4be8dc0b55edc2f0590f84aa to your computer and use it in GitHub Desktop.
Save whatalnk/67147ada4be8dc0b55edc2f0590f84aa to your computer and use it in GitHub Desktop.
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