結果

問題 No.2331 Maximum Quadrilateral
ユーザー とりゐとりゐ
提出日時 2023-05-28 14:39:39
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,192 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 78,932 KB
最終ジャッジ日時 2023-08-27 10:17:46
合計ジャッジ時間 6,246 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,084 KB
testcase_01 AC 84 ms
71,224 KB
testcase_02 AC 86 ms
75,264 KB
testcase_03 AC 87 ms
75,332 KB
testcase_04 AC 86 ms
75,324 KB
testcase_05 AC 91 ms
76,020 KB
testcase_06 AC 86 ms
71,324 KB
testcase_07 AC 89 ms
75,188 KB
testcase_08 AC 89 ms
75,444 KB
testcase_09 AC 82 ms
71,304 KB
testcase_10 AC 86 ms
75,284 KB
testcase_11 AC 82 ms
71,304 KB
testcase_12 AC 82 ms
71,336 KB
testcase_13 AC 82 ms
71,280 KB
testcase_14 AC 85 ms
71,328 KB
testcase_15 AC 79 ms
71,484 KB
testcase_16 AC 82 ms
71,468 KB
testcase_17 AC 79 ms
71,016 KB
testcase_18 AC 80 ms
71,252 KB
testcase_19 AC 78 ms
71,228 KB
testcase_20 AC 87 ms
75,296 KB
testcase_21 AC 87 ms
75,324 KB
testcase_22 AC 87 ms
75,332 KB
testcase_23 AC 89 ms
75,324 KB
testcase_24 AC 86 ms
71,484 KB
testcase_25 AC 75 ms
71,204 KB
testcase_26 AC 75 ms
71,392 KB
testcase_27 AC 76 ms
71,228 KB
testcase_28 AC 76 ms
71,232 KB
testcase_29 AC 75 ms
71,564 KB
testcase_30 RE -
testcase_31 AC 76 ms
71,364 KB
testcase_32 AC 79 ms
71,084 KB
testcase_33 AC 76 ms
71,312 KB
testcase_34 AC 77 ms
71,312 KB
testcase_35 AC 76 ms
71,428 KB
testcase_36 AC 77 ms
71,380 KB
testcase_37 AC 76 ms
71,524 KB
testcase_38 AC 76 ms
71,080 KB
testcase_39 AC 76 ms
71,340 KB
testcase_40 AC 76 ms
71,428 KB
testcase_41 AC 76 ms
71,276 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 AC 76 ms
71,208 KB
testcase_46 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

xy.sort()
xy=convex_hull(xy)[:-1]
n=len(xy)
assert len(xy)>=4
xy=xy+xy

def calc(L,R,mid):
  x1,y1=xy[L]
  x2,y2=xy[R]
  x3,y3=xy[mid]
  dx1=x3-x1
  dy1=y3-y1
  dx2=x2-x1
  dy2=y2-y1
  return -abs(dy1*dx2-dx1*dy2)

def get(L,R):
  l=L
  r=R
  while l+2<r:
    c1=l+(r-l)//3
    c2=r-(r-l)//3
    if calc(L,R,c1)<calc(L,R,c2):
      r=c2
    else:
      l=c1
  ans=10**18
  for i in range(l,r+1):
    ans=min(ans,calc(L,R,i))
  return -ans


ans=0
for i in range(n):
  for j in range(i+2,n):
    ans=max(ans,get(i,j)+get(j,i+n))
    
print(ans)
0