Created
November 19, 2015 10:55
-
-
Save whatalnk/ab0a5e8bbafa1320213f to your computer and use it in GitHub Desktop.
Codeforces #331 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 = 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 |
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 = 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dashboard - Codeforces Round #331 (Div. 2) - Codeforces