結果

問題 No.2012 Largest Triangle
ユーザー shotoyooshotoyoo
提出日時 2022-07-16 00:04:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,153 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 87,432 KB
実行使用メモリ 128,624 KB
最終ジャッジ日時 2023-09-10 06:20:55
合計ジャッジ時間 22,842 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
74,464 KB
testcase_01 AC 116 ms
74,196 KB
testcase_02 WA -
testcase_03 AC 115 ms
74,460 KB
testcase_04 AC 115 ms
74,060 KB
testcase_05 AC 115 ms
74,016 KB
testcase_06 AC 117 ms
74,240 KB
testcase_07 AC 117 ms
74,300 KB
testcase_08 AC 117 ms
74,312 KB
testcase_09 AC 115 ms
74,092 KB
testcase_10 AC 117 ms
74,452 KB
testcase_11 AC 119 ms
74,480 KB
testcase_12 AC 119 ms
74,048 KB
testcase_13 AC 119 ms
74,336 KB
testcase_14 AC 117 ms
74,260 KB
testcase_15 AC 117 ms
74,092 KB
testcase_16 AC 846 ms
122,208 KB
testcase_17 AC 963 ms
128,624 KB
testcase_18 AC 847 ms
122,644 KB
testcase_19 AC 850 ms
121,728 KB
testcase_20 AC 852 ms
121,748 KB
testcase_21 AC 869 ms
122,080 KB
testcase_22 AC 843 ms
121,824 KB
testcase_23 AC 961 ms
127,940 KB
testcase_24 AC 844 ms
121,948 KB
testcase_25 AC 961 ms
128,272 KB
testcase_26 AC 751 ms
121,552 KB
testcase_27 AC 740 ms
121,696 KB
testcase_28 AC 852 ms
128,032 KB
testcase_29 AC 748 ms
121,668 KB
testcase_30 AC 734 ms
121,740 KB
testcase_31 AC 862 ms
122,300 KB
testcase_32 AC 952 ms
128,460 KB
testcase_33 AC 854 ms
121,772 KB
testcase_34 AC 839 ms
121,548 KB
testcase_35 AC 955 ms
128,356 KB
testcase_36 AC 149 ms
81,444 KB
testcase_37 WA -
testcase_38 AC 147 ms
81,276 KB
testcase_39 WA -
testcase_40 AC 149 ms
81,320 KB
testcase_41 AC 317 ms
92,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = lambda : sys.stdin.readline().rstrip()


write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); inf=10**18
LI = lambda : list(map(int, input().split()))
def debug(_l_):
    for s in _l_.split():
        print(f"{s}={eval(s)}", end=" ")
    print()
def dlist(*l, fill=0):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]

from collections import deque
class CHT:
    """傾きが単調減少かつ評価点が単調増加のときの最小値クエリ
    """
    def __init__(self):
        self.q = deque()
    @staticmethod
    def _val(t,x):
        return t[0]*x+t[1]
    @staticmethod
    def _check(t1,t2,t3):
        return (t2[0]-t1[0]) * (t3[1]-t2[1]) >= (t2[1]-t1[1]) * (t3[0]-t2[0])
    def add(self, a, b):
        """a*x + bの追加
        """
        t = (a,b)
        while len(self.q)>=2 and self._check(self.q[-2], self.q[-1], t):
            # 追加する線分と最後から2番めの線分のCHだけで凸包になる
            self.q.pop()
        self.q.append(t)
    def query(self, x):
        """a*x+bの最小値を返す
        """
        while len(self.q)>=2 and self._val(self.q[0], x) >= self._val(self.q[1], x):
            self.q.popleft()
        return self._val(self.q[0], x)
    
n = int(input())
xy = [LI() for _ in range(n)]
zx = None
zy = None
nxy = []
mx = my = 0
for x,y in xy:
    mx = max(mx, abs(x))
    my = max(my, abs(y))
    if x==0:
        zx = (x,y)
    elif y==0:
        zy = (x,y)
    else:
        nxy.append((x,y))
xy = nxy
xy.sort(key=lambda item: item[0])
t = CHT()
t2 = CHT()
for x,y in xy:
    t.add(-x,y)
for x,y in xy[::-1]:
    t2.add(x, -y)
xy.sort(key=lambda item: item[1]/item[0])
ans = 0
for x,y in xy:
    v = t.query(y/x)
    v2 = -t2.query(y/x)
    if x<0:
        ans = max(ans, x*v)
    else:
        ans = max(ans, x*v2)
if zx is not None:
    ans = max(ans, zx[1]*mx)
if zy is not None:
    ans = max(ans, zy[0]*my)
print(int(ans+0.01))
0