Last active
November 25, 2015 11:23
-
-
Save whatalnk/e71b3bda9470cf4234b5 to your computer and use it in GitHub Desktop.
Codeforces 333 Div2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Codeforces Round #333 — editorial - Codeforces