結果

問題 No.2012 Largest Triangle
ユーザー 👑 rin204rin204
提出日時 2022-07-15 22:10:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,070 ms / 2,500 ms
コード長 942 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 101,892 KB
最終ジャッジ日時 2023-09-10 05:47:30
合計ジャッジ時間 24,696 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,252 KB
testcase_01 AC 73 ms
71,300 KB
testcase_02 AC 74 ms
71,196 KB
testcase_03 AC 77 ms
71,044 KB
testcase_04 AC 78 ms
71,044 KB
testcase_05 AC 75 ms
71,076 KB
testcase_06 AC 73 ms
71,296 KB
testcase_07 AC 75 ms
71,296 KB
testcase_08 AC 75 ms
71,252 KB
testcase_09 AC 73 ms
71,092 KB
testcase_10 AC 74 ms
71,228 KB
testcase_11 AC 75 ms
71,512 KB
testcase_12 AC 76 ms
71,040 KB
testcase_13 AC 75 ms
71,348 KB
testcase_14 AC 74 ms
71,044 KB
testcase_15 AC 75 ms
71,300 KB
testcase_16 AC 1,070 ms
100,536 KB
testcase_17 AC 998 ms
100,716 KB
testcase_18 AC 976 ms
100,404 KB
testcase_19 AC 983 ms
100,728 KB
testcase_20 AC 978 ms
100,896 KB
testcase_21 AC 988 ms
100,696 KB
testcase_22 AC 999 ms
100,136 KB
testcase_23 AC 1,009 ms
101,164 KB
testcase_24 AC 993 ms
101,004 KB
testcase_25 AC 1,006 ms
101,092 KB
testcase_26 AC 1,016 ms
101,192 KB
testcase_27 AC 1,024 ms
101,892 KB
testcase_28 AC 1,026 ms
101,488 KB
testcase_29 AC 1,022 ms
101,736 KB
testcase_30 AC 1,011 ms
101,272 KB
testcase_31 AC 986 ms
100,640 KB
testcase_32 AC 985 ms
101,200 KB
testcase_33 AC 983 ms
100,612 KB
testcase_34 AC 984 ms
100,652 KB
testcase_35 AC 965 ms
100,656 KB
testcase_36 AC 95 ms
76,484 KB
testcase_37 AC 97 ms
76,112 KB
testcase_38 AC 99 ms
76,676 KB
testcase_39 AC 96 ms
76,244 KB
testcase_40 AC 99 ms
76,404 KB
testcase_41 AC 230 ms
88,264 KB
権限があれば一括ダウンロードができます

ソースコード

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)
    qs.pop()
    return qs

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xy.sort()
xy = convex_hull(xy)
n = len(xy)
xy += xy

def S(i, j):
    return abs(xy[i][0] * xy[j][1] - xy[i][1] * xy[j][0])

ans = 0
r = 1
for l in range(n):
    bef = S(l, r)
    while S(l, r + 1) >= bef:
        bef = S(l, r + 1)
        r += 1
    ans = max(ans, bef)
print(ans)
0