Skip to content

Instantly share code, notes, and snippets.

@tungaqhd
Created October 20, 2019 03:54
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 tungaqhd/b0eb96f2c23b744f022cc20df40db0b4 to your computer and use it in GitHub Desktop.
Save tungaqhd/b0eb96f2c23b744f022cc20df40db0b4 to your computer and use it in GitHub Desktop.
ver = []
def area(A, B, C):
return 0.5 * abs((ver[B][0] - ver[A][0])*(ver[C][1] - ver[A][1]) - (ver[C][0] - ver[A][0])*(ver[B][1] - ver[A][1]))
n = int(input())
for i in range(n):
x, y = map(int, input().split())
ver.append([x, y])
A = 0; B = 1; C = 2
bA= A; bB= B; bC= C
while True:
while True:
while area(A, B, C) <= area(A, B, (C+1)%n):
C = (C+1)%n
if area(A, B, C) <= area(A, (B+1)%n, C):
B = (B+1)%n
continue
else:
break
if area(A, B, C) > area(bA, bB, bC):
bA = A
bB = B
bC = C
A = (A+1)%n
if A==B:
B = (B+1)%n
if B==C: C = (C+1)%n
if A==0: break
ans = area(bA, bB, bC)
print('{0:.1f}'.format(ans))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment