結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー 👑 Kazun
提出日時 2020-09-15 22:54:19
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 4,662 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 111,492 KB
最終ジャッジ日時 2024-12-27 18:26:56
合計ジャッジ時間 13,756 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40 RE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

def General_Binary_Increase_Search(L,R,cond,Integer=True,ep=1/(1<<20)):
"""調,.
L:
R:
cond:(1,調 or 調)
Integer:?
ep:Integer=False,
"""
if not(cond(R)):
return False
if Integer:
R+=1
while R-L>1:
C=L+(R-L)//2
if cond(C):
R=C
else:
L=C
return R
else:
while (R-L)>=ep:
C=L+(R-L)/2
if cond(C):
R=C
else:
L=C
return R
#================================================
def f(x): #
Z=0
I=0
for u in U_pos:
if I<V_negative:
while u*V_neg[I]<=x:
I+=1
if I==V_negative:
break
Z+=I
I=0
for v in V_pos:
if I<U_negative:
while v*U_neg[I]<=x:
I+=1
if I==U_negative:
break
Z+=I
return Z
def g(x): #
Z=0
I=V_positive
for u in U_pos:
if I>0:
while u*V_pos[I-1]>x:
I-=1
if I==0:
break
Z+=I
I=0
for v in V_neg:
if I<U_negative:
while v*U_neg[-(I+1)]<=x:
I+=1
if I==U_negative:
break
Z+=I
return Z
#================================================
# pq=x p in G,q in H .
def h(x,G,H):
if x==0:
if 0 in G:
return (0,H[0])
else:
return (G[0],0)
H=set(H)
for g in G:
if g==0:
continue
if (x%g==0) and (x//g in H):
return (g,x//g)
return None
#================================================
#
K,L,M,N,S=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
D=list(map(int,input().split()))
#================================================
#
assert 1<=K<=500,"K(K={})".format(K)
assert 1<=L<=500,"L(L={})".format(L)
assert 1<=M<=500,"M(M={})".format(M)
assert 1<=N<=500,"N(N={})".format(N)
assert 1<=S<=K*L*M*N,"S(S={})".format(S)
assert len(A)==K,"A(K={},A={})".format(K,len(A))
assert len(B)==L,"B(L={},B={})".format(L,len(B))
assert len(C)==M,"C(M={},C={})".format(M,len(C))
assert len(D)==N,"D(N={},D={})".format(N,len(D))
A_abs_max=abs(max(A,key=lambda a:abs(a)))
B_abs_max=abs(max(B,key=lambda b:abs(b)))
C_abs_max=abs(max(C,key=lambda c:abs(c)))
D_abs_max=abs(max(D,key=lambda d:abs(d)))
assert A_abs_max<=3*10**4,"A(max |A|={})".format(A_abs_max)
assert B_abs_max<=3*10**4,"B(max |B|={})".format(B_abs_max)
assert C_abs_max<=3*10**4,"C(max |C|={})".format(C_abs_max)
assert D_abs_max<=3*10**4,"D(max |D|={})".format(D_abs_max)
#================================================
# (A,B),(C,D)2.
U=[a*b for a in A for b in B]
U.sort()
V=[c*d for c in C for d in D]
V.sort()
U_pos=[u for u in U if u>0]
U_neg=[u for u in U if u<0]
V_pos=[v for v in V if v>0]
V_neg=[v for v in V if v<0]
U_positive=len(U_pos)
U_negative=len(U_neg)
U_zero=K*L-(U_positive+U_negative)
V_positive=len(V_pos)
V_negative=len(V_neg)
V_zero=M*N-(V_positive+V_negative)
#================================================
# E,,
E_positive=U_positive*V_positive+U_negative*V_negative
E_negative=U_positive*V_negative+U_negative*V_positive
E_zero=K*L*M*N-(E_positive+E_negative)
#================================================
# J.
U_abs_max=abs(max(U,key=lambda u:abs(u)))
V_abs_max=abs(max(V,key=lambda v:abs(v)))
Abs_max=U_abs_max*V_abs_max+1
if S<=E_negative: #
Ans=General_Binary_Increase_Search(-Abs_max,0,lambda x:f(x)>=S)
elif E_negative+1<=S<=E_negative+E_zero: #
Ans=0
else: #
Ans=General_Binary_Increase_Search(0,Abs_max,lambda x:g(x)>=S-(E_negative+E_zero))
#================================================
# T=abcd a,b,c,d.
alpha,beta=h(Ans,U,V)
a,b=h(alpha,A,B)
c,d=h(beta ,C,D)
#================================================
#
print(Ans)
print(a,b,c,d)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0