結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー 👑 KazunKazun
提出日時 2020-11-01 17:58:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,960 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 130,804 KB
最終ジャッジ日時 2023-08-27 16:16:27
合計ジャッジ時間 27,158 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,432 KB
testcase_01 AC 63 ms
71,404 KB
testcase_02 AC 71 ms
75,660 KB
testcase_03 AC 74 ms
75,920 KB
testcase_04 AC 64 ms
71,612 KB
testcase_05 AC 66 ms
71,280 KB
testcase_06 AC 63 ms
71,576 KB
testcase_07 AC 65 ms
71,304 KB
testcase_08 AC 94 ms
76,912 KB
testcase_09 AC 83 ms
76,824 KB
testcase_10 AC 103 ms
77,044 KB
testcase_11 AC 96 ms
76,948 KB
testcase_12 AC 94 ms
76,840 KB
testcase_13 AC 109 ms
76,864 KB
testcase_14 AC 88 ms
76,704 KB
testcase_15 AC 107 ms
77,016 KB
testcase_16 AC 93 ms
77,012 KB
testcase_17 AC 110 ms
77,080 KB
testcase_18 AC 372 ms
78,488 KB
testcase_19 AC 224 ms
77,376 KB
testcase_20 AC 478 ms
77,676 KB
testcase_21 AC 158 ms
78,652 KB
testcase_22 AC 230 ms
78,312 KB
testcase_23 AC 297 ms
79,500 KB
testcase_24 AC 262 ms
79,792 KB
testcase_25 AC 295 ms
79,436 KB
testcase_26 AC 335 ms
79,448 KB
testcase_27 AC 292 ms
77,568 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 1,954 ms
130,804 KB
testcase_33 AC 1,816 ms
92,900 KB
testcase_34 TLE -
testcase_35 TLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def Binary_Search_Small_Count(A,x,equal=False,sort=False):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    if sort:
        A.sort()

    if A[0]>x or ((not equal) and A[0]==x):
        return 0

    L,R=0,len(A)
    while R-L>1:
        C=L+(R-L)//2
        if A[C]<x or (equal and A[C]==x):
            L=C
        else:
            R=C

    return L+1

def Binary_Search_Big_Count(A,x,equal=False,sort=False):
    """2分探索によって,xを超える要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"を超える"がx"以上"になる
    """

    if sort:
        A.sort()

    if A[-1]<x or ((not equal) and A[-1]==x):
        return 0

    L,R=-1,len(A)-1
    while R-L>1:
        C=L+(R-L)//2
        if A[C]>x or (equal and A[C]==x):
            R=C
        else:
            L=C
    return len(A)-R

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 g(x):
    S=0
    for u in U:
        if u>0:
            S+=Binary_Search_Small_Count(V,x//u,True)
        elif u<0:
            S+=Binary_Search_Big_Count(V,(-x-u-1)//(-u),True)
        else:
            if x>=0:
                S+=len(V)
    return S

def h(A,B,x):
    G=set(B)
    b=B[0]

    for a in A:
        if a==0:
            if x==0:
                return (0,b)
        elif (x%a==0) and (x//a in G):
            return (a,x//a)
    return None
#=================================================
import sys
input=sys.stdin.readline

K,L,M,N,P=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()))

U=[a*b for a in A for b in B]
V=[c*d for c in C for d in D]
V.sort()

E_abs_max=max(U,key=lambda u:abs(u))*max(V,key=lambda v:abs(v))
E_abs_max=abs(E_abs_max)+1

J=General_Binary_Increase_Search(-E_abs_max,E_abs_max,lambda x:g(x)>=P,True)

p,q=h(U,V,J)
a,b=h(A,B,p)
c,d=h(C,D,q)

print(J)
print(a,b,c,d)
0