結果
問題 | No.2012 Largest Triangle |
ユーザー | googol_S0 |
提出日時 | 2022-07-15 23:05:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,260 ms / 2,500 ms |
コード長 | 1,750 bytes |
コンパイル時間 | 322 ms |
コンパイル使用メモリ | 87,272 KB |
実行使用メモリ | 123,136 KB |
最終ジャッジ日時 | 2023-09-10 05:51:45 |
合計ジャッジ時間 | 32,301 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 215 ms
89,324 KB |
testcase_01 | AC | 213 ms
89,344 KB |
testcase_02 | AC | 210 ms
89,388 KB |
testcase_03 | AC | 216 ms
89,516 KB |
testcase_04 | AC | 212 ms
89,468 KB |
testcase_05 | AC | 211 ms
89,480 KB |
testcase_06 | AC | 215 ms
89,548 KB |
testcase_07 | AC | 214 ms
89,084 KB |
testcase_08 | AC | 215 ms
89,548 KB |
testcase_09 | AC | 215 ms
89,380 KB |
testcase_10 | AC | 212 ms
89,132 KB |
testcase_11 | AC | 216 ms
89,324 KB |
testcase_12 | AC | 215 ms
89,360 KB |
testcase_13 | AC | 220 ms
89,388 KB |
testcase_14 | AC | 216 ms
89,332 KB |
testcase_15 | AC | 215 ms
89,468 KB |
testcase_16 | AC | 1,221 ms
121,660 KB |
testcase_17 | AC | 1,188 ms
117,848 KB |
testcase_18 | AC | 1,193 ms
117,728 KB |
testcase_19 | AC | 1,149 ms
113,332 KB |
testcase_20 | AC | 1,193 ms
121,116 KB |
testcase_21 | AC | 1,149 ms
112,960 KB |
testcase_22 | AC | 1,152 ms
113,024 KB |
testcase_23 | AC | 1,202 ms
120,224 KB |
testcase_24 | AC | 1,156 ms
113,164 KB |
testcase_25 | AC | 1,212 ms
121,736 KB |
testcase_26 | AC | 1,147 ms
118,496 KB |
testcase_27 | AC | 1,147 ms
123,136 KB |
testcase_28 | AC | 1,142 ms
114,148 KB |
testcase_29 | AC | 1,152 ms
119,504 KB |
testcase_30 | AC | 1,143 ms
113,904 KB |
testcase_31 | AC | 1,187 ms
113,696 KB |
testcase_32 | AC | 1,192 ms
113,988 KB |
testcase_33 | AC | 1,260 ms
121,988 KB |
testcase_34 | AC | 1,219 ms
122,672 KB |
testcase_35 | AC | 1,183 ms
113,900 KB |
testcase_36 | AC | 254 ms
92,704 KB |
testcase_37 | AC | 251 ms
93,172 KB |
testcase_38 | AC | 253 ms
93,032 KB |
testcase_39 | AC | 248 ms
93,056 KB |
testcase_40 | AC | 253 ms
92,884 KB |
testcase_41 | AC | 457 ms
100,816 KB |
ソースコード
from decimal import * def sgn(x): if x==0: return 0 if x>0: return 1 return -1 def check(a,b,c): #if a==b or b==c: # return sgn(b[0]-a[0])*sgn(c[1]-b[1])>=sgn(c[0]-b[0])*sgn(b[1]-a[1]) return (b[0]-a[0])*(c[1]-b[1])>=(c[0]-b[0])*(b[1]-a[1]) def get_y(a,x): return a[0]*x+a[1] from collections import deque class CHT: __slots__=['H','F'] def __init__(self,f): self.H=deque() self.F=f def add(self,x): h=self.H if self.F: x=(-x[0],-x[1]) if len(h)==0: h.append(x) return 0 if h[0][0]<=x[0]: if h[0][0]==x[0]: if h[0][1]<=x[1]: return 0 h.popleft() while(len(h)>=2 and check(x,h[0],h[1])): h.popleft() h.appendleft(x) else: if(h[-1][0]==x[0]): if(h[-1][1]<=x[1]): return 0 h.pop() while(len(h)>=2 and check(h[-2],h[-1],x)): h.pop() h.append(x) def query_i(self,x): h=self.H a=h[0] if len(h)>=2: b=h[1] while(len(h)>=2 and a[0]*x+a[1]>=b[0]*x+b[1]): h.popleft() a=b if len(h)<2: break b=h[1] if self.F: return -a[0]*x-a[1] else: return a[0]*x+a[1] getcontext().prec=30 Decimal=lambda x:x N=int(input()) eps=Decimal('1e-12') eps=float(eps) X=[tuple(map(lambda x:Decimal(int(x)+eps),input().split())) for i in range(N)] A=CHT(True) B=CHT(False) X.sort(key=lambda x:x[1]) for i in range(N): a,b=X[i][0],X[i][1] A.add((b,-a)) B.add((b,-a)) X.sort(key=lambda x:x[0]/x[1]) ANS=0 for i in range(N): a,b=X[i][0],X[i][1] x,y=B.query_i(a/b),A.query_i(a/b) ANS=max(ANS,-x*b,-y*b,x*b,y*b) if b>=0: ANS=max(ANS,x*b,-y*b) else: ANS=max(ANS,-x*b,y*b) print(round(ANS))