Create a gist now

Instantly share code, notes, and snippets.

Codeforces #331 Div2
n = gets.chomp.to_i
coors = []
n.times do
coors << gets.chomp.split(" ").map(&:to_i)
end
if n == 3 or n == 4 then
coors_t = coors.transpose
dx = coors_t[0].max - coors_t[0].min
dy = coors_t[1].max - coors_t[1].min
puts dx * dy
elsif n == 2
if coors[0][0] != coors[1][0] and coors[0][1] != coors[1][1] then
dx = (coors[0][0] - coors[1][0]).abs
dy = (coors[0][1] - coors[1][1]).abs
puts dx * dy
else
puts -1
end
else
puts -1
end
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
e = 0
res = 0
n.times do |i|
res += (a[i] - e).abs
e = a[i]
end
puts res
@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