結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,940 KB
testcase_01 AC 73 ms
71,592 KB
testcase_02 AC 73 ms
71,052 KB
testcase_03 AC 73 ms
71,404 KB
testcase_04 AC 74 ms
71,192 KB
testcase_05 AC 75 ms
71,400 KB
testcase_06 AC 73 ms
71,360 KB
testcase_07 AC 74 ms
71,352 KB
testcase_08 AC 73 ms
71,456 KB
testcase_09 AC 73 ms
71,240 KB
testcase_10 AC 74 ms
71,276 KB
testcase_11 AC 76 ms
71,260 KB
testcase_12 AC 75 ms
71,460 KB
testcase_13 AC 75 ms
71,500 KB
testcase_14 AC 75 ms
71,208 KB
testcase_15 AC 74 ms
71,160 KB
testcase_16 AC 747 ms
91,192 KB
testcase_17 AC 753 ms
90,892 KB
testcase_18 AC 749 ms
90,704 KB
testcase_19 AC 745 ms
91,204 KB
testcase_20 AC 750 ms
91,096 KB
testcase_21 AC 748 ms
91,148 KB
testcase_22 AC 721 ms
90,100 KB
testcase_23 AC 734 ms
91,384 KB
testcase_24 AC 737 ms
91,492 KB
testcase_25 AC 726 ms
91,488 KB
testcase_26 AC 1,650 ms
91,240 KB
testcase_27 AC 1,480 ms
91,740 KB
testcase_28 AC 1,643 ms
91,204 KB
testcase_29 AC 1,617 ms
91,572 KB
testcase_30 AC 1,660 ms
91,636 KB
testcase_31 AC 754 ms
91,060 KB
testcase_32 AC 751 ms
91,460 KB
testcase_33 AC 750 ms
91,136 KB
testcase_34 AC 750 ms
91,156 KB
testcase_35 AC 743 ms
91,012 KB
testcase_36 AC 103 ms
76,536 KB
testcase_37 AC 102 ms
76,632 KB
testcase_38 AC 103 ms
76,576 KB
testcase_39 AC 101 ms
76,612 KB
testcase_40 AC 102 ms
76,692 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