結果
問題 | No.2331 Maximum Quadrilateral |
ユーザー | qib |
提出日時 | 2023-05-29 22:50:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 1,650 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 66,048 KB |
最終ジャッジ日時 | 2024-06-08 19:33:13 |
合計ジャッジ時間 | 3,606 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
64,640 KB |
testcase_01 | AC | 54 ms
61,824 KB |
testcase_02 | AC | 57 ms
62,976 KB |
testcase_03 | AC | 61 ms
65,152 KB |
testcase_04 | AC | 60 ms
64,512 KB |
testcase_05 | AC | 62 ms
66,048 KB |
testcase_06 | AC | 55 ms
62,464 KB |
testcase_07 | AC | 56 ms
63,360 KB |
testcase_08 | AC | 60 ms
64,128 KB |
testcase_09 | AC | 52 ms
61,440 KB |
testcase_10 | AC | 59 ms
64,256 KB |
testcase_11 | AC | 47 ms
55,168 KB |
testcase_12 | AC | 54 ms
62,208 KB |
testcase_13 | AC | 54 ms
62,080 KB |
testcase_14 | AC | 57 ms
62,720 KB |
testcase_15 | AC | 42 ms
53,504 KB |
testcase_16 | AC | 55 ms
61,824 KB |
testcase_17 | AC | 42 ms
53,504 KB |
testcase_18 | AC | 50 ms
60,160 KB |
testcase_19 | AC | 41 ms
53,760 KB |
testcase_20 | AC | 59 ms
63,872 KB |
testcase_21 | AC | 58 ms
64,128 KB |
testcase_22 | AC | 63 ms
64,640 KB |
testcase_23 | AC | 61 ms
65,024 KB |
testcase_24 | AC | 60 ms
64,512 KB |
testcase_25 | AC | 39 ms
52,096 KB |
testcase_26 | AC | 40 ms
52,224 KB |
testcase_27 | AC | 40 ms
52,096 KB |
testcase_28 | AC | 39 ms
52,096 KB |
testcase_29 | AC | 39 ms
52,608 KB |
testcase_30 | AC | 37 ms
52,352 KB |
testcase_31 | AC | 37 ms
52,224 KB |
testcase_32 | AC | 38 ms
52,224 KB |
testcase_33 | AC | 38 ms
52,480 KB |
testcase_34 | AC | 39 ms
52,352 KB |
testcase_35 | AC | 39 ms
52,352 KB |
testcase_36 | AC | 39 ms
52,608 KB |
testcase_37 | AC | 39 ms
52,096 KB |
testcase_38 | AC | 38 ms
52,352 KB |
testcase_39 | AC | 39 ms
52,224 KB |
testcase_40 | AC | 39 ms
51,968 KB |
testcase_41 | AC | 38 ms
52,352 KB |
testcase_42 | AC | 38 ms
52,096 KB |
testcase_43 | AC | 39 ms
51,968 KB |
testcase_44 | AC | 39 ms
51,968 KB |
testcase_45 | AC | 39 ms
52,224 KB |
testcase_46 | AC | 40 ms
51,968 KB |
ソースコード
INF = 1 << 60 def cross(ux, uy, vx, vy): return vy * ux - vx * uy n = int(input()) points = [list(map(int, input().split())) for _ in range(n)] points.sort() conv = [] for i in range(n): x, y = points[i] while len(conv) >= 2: ux = conv[-2][0] - conv[-1][0] uy = conv[-2][1] - conv[-1][1] vx = conv[-1][0] - x vy = conv[-1][1] - y if cross(ux, uy, vx, vy) > 0: conv.pop() else: break conv.append((x, y)) for i in range(len(points) - 2, -1, -1): x, y = points[i] while len(conv) >= 2: ux = conv[-2][0] - conv[-1][0] uy = conv[-2][1] - conv[-1][1] vx = conv[-1][0] - x vy = conv[-1][1] - y if cross(ux, uy, vx, vy) > 0: conv.pop() else: break conv.append((x, y)) conv.pop() ans = - INF if len(conv) == 3: for c in range(n): if tuple(points[c]) in conv: continue xc, yc = points[c] q = [] for d in range(3): xi, yi = conv[d] xj, yj = conv[(d + 1) % 3] area = abs((yj - yc) * (xi - xc) - (xj - xc) * (yi - yc)) q.append(area) q.sort() ans = max(ans, q[-2] + q[-1]) print(ans) exit() for l in range(len(conv)): xl, yl = conv[l] for j in range(len(conv) - 3): mid = (l + j + 2) % len(conv) xm, ym = conv[mid] al = - INF ar = - INF flg = False for k in range(len(conv) - 1): r = (l + k + 1) % len(conv) if r == mid: flg = True continue xr, yr = conv[r] area = abs((yr - yl) * (xm - xl) - (xr - xl) * (ym - yl)) if flg: ar = max(ar, area) else: al = max(al, area) ans = max(ans, al + ar) print(ans)