結果
問題 | No.2012 Largest Triangle |
ユーザー | googol_S0 |
提出日時 | 2022-07-15 22:32:08 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,625 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 11,188 KB |
実行使用メモリ | 93,484 KB |
最終ジャッジ日時 | 2023-09-10 03:20:14 |
合計ジャッジ時間 | 63,859 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 23 ms
9,356 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 22 ms
9,220 KB |
testcase_05 | WA | - |
testcase_06 | AC | 21 ms
9,200 KB |
testcase_07 | WA | - |
testcase_08 | AC | 22 ms
9,352 KB |
testcase_09 | AC | 21 ms
9,188 KB |
testcase_10 | AC | 22 ms
9,380 KB |
testcase_11 | AC | 24 ms
9,216 KB |
testcase_12 | WA | - |
testcase_13 | AC | 24 ms
9,288 KB |
testcase_14 | WA | - |
testcase_15 | AC | 24 ms
9,220 KB |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | AC | 35 ms
9,792 KB |
testcase_37 | AC | 36 ms
9,816 KB |
testcase_38 | AC | 36 ms
9,796 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
ソースコード
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] N=int(input()) eps=1e-12 X=[tuple(map(lambda x:Decimal(int(x)+eps),input().split())) for i in range(N)] X.sort(key=lambda x:x[0]/x[1]) A=CHT(False) B=CHT(False) getcontext().prec=30 ANS=0 for i in range(N): a,b=X[i][0],X[i][1] if i: ANS=max(ANS,B.query_i(a/b)*b) B.add((b,-a)) for i in range(N): a,b=X[i][0],X[i][1] if i: ANS=max(ANS,-A.query_i(a/b)*b) A.add((-b,a)) print(round(ANS))