結果

問題 No.2012 Largest Triangle
ユーザー shotoyooshotoyoo
提出日時 2022-07-16 00:03:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,153 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 122,628 KB
最終ジャッジ日時 2023-09-10 06:20:10
合計ジャッジ時間 24,272 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
73,948 KB
testcase_01 AC 120 ms
74,256 KB
testcase_02 WA -
testcase_03 AC 118 ms
74,416 KB
testcase_04 AC 117 ms
74,216 KB
testcase_05 AC 120 ms
74,260 KB
testcase_06 AC 120 ms
74,104 KB
testcase_07 AC 120 ms
73,764 KB
testcase_08 AC 122 ms
74,380 KB
testcase_09 AC 120 ms
74,308 KB
testcase_10 AC 120 ms
74,204 KB
testcase_11 AC 124 ms
73,940 KB
testcase_12 AC 120 ms
74,308 KB
testcase_13 AC 121 ms
73,956 KB
testcase_14 AC 123 ms
74,436 KB
testcase_15 AC 123 ms
74,228 KB
testcase_16 AC 897 ms
121,748 KB
testcase_17 AC 868 ms
122,080 KB
testcase_18 AC 868 ms
122,532 KB
testcase_19 AC 872 ms
121,560 KB
testcase_20 AC 937 ms
122,240 KB
testcase_21 AC 856 ms
122,020 KB
testcase_22 AC 862 ms
122,412 KB
testcase_23 AC 869 ms
122,420 KB
testcase_24 AC 867 ms
122,136 KB
testcase_25 AC 866 ms
122,388 KB
testcase_26 AC 759 ms
121,848 KB
testcase_27 AC 800 ms
121,860 KB
testcase_28 AC 765 ms
122,092 KB
testcase_29 AC 747 ms
121,712 KB
testcase_30 AC 795 ms
122,080 KB
testcase_31 AC 832 ms
122,148 KB
testcase_32 AC 844 ms
122,284 KB
testcase_33 AC 838 ms
122,440 KB
testcase_34 AC 838 ms
121,884 KB
testcase_35 AC 857 ms
122,628 KB
testcase_36 AC 150 ms
80,880 KB
testcase_37 WA -
testcase_38 AC 151 ms
81,132 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 322 ms
93,112 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 = []
for x,y in xy:
    if x==0:
        zx = (x,y)
    elif y==0:
        zy = (x,y)
    else:
        nxy.append((x,y))
mx = my = 0
xy = nxy
xy.sort(key=lambda item: item[0])
t = CHT()
t2 = CHT()
for x,y in xy:
    t.add(-x,y)
    mx = max(mx, abs(x))
    my = max(my, abs(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