-
-
Save tungaqhd/b0eb96f2c23b744f022cc20df40db0b4 to your computer and use it in GitHub Desktop.
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
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