結果

問題 No.2012 Largest Triangle
ユーザー とりゐとりゐ
提出日時 2022-07-15 21:44:43
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 823 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 91,508 KB
最終ジャッジ日時 2023-09-10 05:45:10
合計ジャッジ時間 28,367 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,540 KB
testcase_01 AC 74 ms
71,176 KB
testcase_02 AC 74 ms
71,564 KB
testcase_03 AC 74 ms
71,156 KB
testcase_04 AC 74 ms
71,248 KB
testcase_05 AC 75 ms
71,492 KB
testcase_06 AC 73 ms
70,996 KB
testcase_07 AC 72 ms
71,188 KB
testcase_08 AC 73 ms
71,324 KB
testcase_09 AC 72 ms
71,168 KB
testcase_10 AC 73 ms
71,248 KB
testcase_11 AC 75 ms
71,500 KB
testcase_12 AC 74 ms
71,076 KB
testcase_13 AC 75 ms
71,216 KB
testcase_14 AC 76 ms
71,292 KB
testcase_15 AC 74 ms
71,344 KB
testcase_16 AC 759 ms
91,168 KB
testcase_17 AC 746 ms
90,960 KB
testcase_18 AC 748 ms
90,696 KB
testcase_19 AC 752 ms
91,004 KB
testcase_20 AC 750 ms
91,088 KB
testcase_21 AC 744 ms
91,068 KB
testcase_22 AC 726 ms
90,408 KB
testcase_23 AC 743 ms
91,500 KB
testcase_24 AC 733 ms
91,440 KB
testcase_25 AC 739 ms
91,360 KB
testcase_26 AC 1,749 ms
90,524 KB
testcase_27 AC 1,546 ms
91,016 KB
testcase_28 AC 1,689 ms
90,624 KB
testcase_29 AC 1,680 ms
91,440 KB
testcase_30 AC 1,739 ms
91,256 KB
testcase_31 AC 756 ms
90,452 KB
testcase_32 AC 752 ms
91,508 KB
testcase_33 AC 756 ms
91,056 KB
testcase_34 AC 771 ms
91,040 KB
testcase_35 AC 760 ms
91,028 KB
testcase_36 AC 104 ms
76,688 KB
testcase_37 AC 106 ms
76,748 KB
testcase_38 AC 104 ms
76,744 KB
testcase_39 AC 103 ms
76,632 KB
testcase_40 AC 103 ms
76,808 KB
testcase_41 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def cross3(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])

# ps = [(x, y), ...]: ソートされた座標list
def convex_hull(ps):
    qs = []
    N = len(ps)
    for p in ps:
        # 一直線上で高々2点にする場合は ">=" にする
        while len(qs) > 1 and cross3(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(N-2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross3(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs

n=int(input())
xy=[]
for i in range(n):
  x,y=map(int,input().split())
  xy.append((x,y))

xy.sort()
xy=convex_hull(xy)
m=len(xy)

ans=0
for i in range(m):
  for j in range(i+1,m):
    xi,yi=xy[i]
    xj,yj=xy[j]
    s=abs(xi*yj-xj*yi)
    ans=max(ans,s)

print(ans)
0