結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー 👑 KazunKazun
提出日時 2020-09-14 22:55:10
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 3,445 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 182,736 KB
最終ジャッジ日時 2023-08-27 16:09:39
合計ジャッジ時間 30,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 65 ms
71,300 KB
testcase_02 AC 64 ms
71,032 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 AC 595 ms
182,736 KB
testcase_49 AC 390 ms
182,632 KB
testcase_50 AC 582 ms
182,448 KB
testcase_51 AC 481 ms
182,512 KB
testcase_52 AC 593 ms
182,328 KB
testcase_53 AC 906 ms
156,760 KB
testcase_54 AC 859 ms
156,704 KB
testcase_55 RE -
testcase_56 AC 895 ms
156,796 KB
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 AC 64 ms
71,220 KB
testcase_72 AC 64 ms
71,436 KB
testcase_73 RE -
権限があれば一括ダウンロードができます

ソースコード

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==U_positive:
                    break
        Z+=I

    I=0
    for v in V_pos:
        if I<U_negative:
            while v*U_neg[I]<=x:
                I+=1

                if I==V_positive:
                    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_positive:
                    break
        Z+=I

    return Z
#================================================
# pq=x なる x in G,y in H を求める.
def h(x,G,H):
    H=set(H)

    for g in G:
        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()))

#================================================
# (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

if K<=E_negative: #負確定
    Ans=General_Binary_Increase_Search(-Abs_max,0,lambda x:f(x)>=S)
elif E_negative+1<=K<=E_negative+E_zero: #ゼロ確定
    Ans=0
else: #正確定
    Ans=General_Binary_Increase_Search(0,Abs_max,lambda x:g(x)>=S-(E_negative+E_zero))

#================================================
# J=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)
0