Create a gist now

Instantly share code, notes, and snippets.

Codeforces 333 Div2
n, bx = gets.chomp.split(" ").map(&:to_i)
xs = gets.chomp.split(" ").map(&:to_i)
m, by = gets.chomp.split(" ").map(&:to_i)
ys = gets.chomp.split(" ").map(&:to_i)
bxx = (0..(n-1)).map{|i| bx**i}.reverse
byy = (0..(m-1)).map{|i| by**i}.reverse
x = xs.zip(bxx).map{|i, j| i*j}.inject(:+)
y = ys.zip(byy).map{|i, j| i*j}.inject(:+)
if x == y then
puts "="
elsif x < y then
puts "<"
else
puts ">"
end
# 14462223
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
left = 0
prev = 0
ans = 1
tmp = 0
(1...n).each do |i|
d = a[i] - a[i-1]
if d != 0 then
if d == tmp then
left = prev + 1
end
tmp = d
prev = i - 1
end
ans = [ans, i - left + 1].max
end
puts ans
@whatalnk
Owner
  • A
  • B
  • C
  • D
  • E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment