結果

問題 No.2331 Maximum Quadrilateral
ユーザー qibqib
提出日時 2023-05-29 22:15:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,287 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 76,628 KB
最終ジャッジ日時 2023-08-27 23:57:41
合計ジャッジ時間 6,868 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,620 KB
testcase_01 AC 81 ms
76,028 KB
testcase_02 AC 83 ms
76,268 KB
testcase_03 AC 89 ms
76,348 KB
testcase_04 AC 86 ms
76,280 KB
testcase_05 AC 92 ms
76,412 KB
testcase_06 AC 82 ms
76,068 KB
testcase_07 AC 82 ms
75,908 KB
testcase_08 AC 85 ms
76,120 KB
testcase_09 AC 79 ms
76,048 KB
testcase_10 AC 86 ms
75,984 KB
testcase_11 AC 76 ms
71,284 KB
testcase_12 AC 80 ms
76,048 KB
testcase_13 AC 80 ms
75,960 KB
testcase_14 AC 82 ms
76,004 KB
testcase_15 AC 72 ms
71,396 KB
testcase_16 AC 80 ms
76,088 KB
testcase_17 AC 70 ms
71,432 KB
testcase_18 AC 76 ms
76,060 KB
testcase_19 AC 72 ms
71,336 KB
testcase_20 AC 84 ms
76,136 KB
testcase_21 AC 85 ms
76,044 KB
testcase_22 AC 88 ms
76,080 KB
testcase_23 AC 87 ms
76,220 KB
testcase_24 AC 86 ms
76,628 KB
testcase_25 AC 68 ms
71,296 KB
testcase_26 AC 70 ms
71,432 KB
testcase_27 AC 69 ms
71,144 KB
testcase_28 AC 67 ms
71,516 KB
testcase_29 AC 68 ms
71,504 KB
testcase_30 WA -
testcase_31 AC 66 ms
71,320 KB
testcase_32 AC 67 ms
71,200 KB
testcase_33 AC 68 ms
71,140 KB
testcase_34 AC 67 ms
71,452 KB
testcase_35 AC 70 ms
71,364 KB
testcase_36 AC 69 ms
71,300 KB
testcase_37 AC 68 ms
71,280 KB
testcase_38 AC 70 ms
71,144 KB
testcase_39 AC 68 ms
71,304 KB
testcase_40 AC 71 ms
71,568 KB
testcase_41 AC 71 ms
71,144 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 69 ms
71,336 KB
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = 0
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)
0