結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー vwxyzvwxyz
提出日時 2023-12-01 01:55:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,602 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 141,248 KB
最終ジャッジ日時 2023-12-01 01:56:10
合計ジャッジ時間 22,195 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 AC 39 ms
53,460 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
testcase_31 RE -
testcase_32 WA -
testcase_33 RE -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 RE -
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 WA -
testcase_44 RE -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 892 ms
128,148 KB
testcase_54 AC 851 ms
141,168 KB
testcase_55 WA -
testcase_56 AC 854 ms
141,172 KB
testcase_57 WA -
testcase_58 AC 378 ms
123,256 KB
testcase_59 AC 378 ms
123,256 KB
testcase_60 AC 477 ms
123,220 KB
testcase_61 AC 479 ms
123,220 KB
testcase_62 AC 481 ms
123,220 KB
testcase_63 AC 47 ms
62,092 KB
testcase_64 AC 47 ms
62,092 KB
testcase_65 AC 48 ms
62,092 KB
testcase_66 AC 48 ms
62,092 KB
testcase_67 AC 47 ms
62,092 KB
testcase_68 AC 37 ms
53,460 KB
testcase_69 AC 38 ms
53,460 KB
testcase_70 AC 56 ms
53,460 KB
testcase_71 AC 37 ms
53,460 KB
testcase_72 AC 37 ms
53,460 KB
testcase_73 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline
import bisect

def Bisect_Int(ok,ng,is_ok):
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if is_ok(mid):
            ok=mid
        else:
            ng=mid
    return ok

K,L,M,N,S=map(int,readline().split())
A=list(map(int,readline().split()))
B=list(map(int,readline().split()))
C=list(map(int,readline().split()))
D=list(map(int,readline().split()))
plus0,minus0,zero0=[],[],0
for a in A:
    for b in B:
        if a*b>0:
            plus0.append(a*b)
        elif a*b<0:
            minus0.append(-a*b)
        else:
            zero0+=1
plus1,minus1,zero1=[],[],0
for c in C:
    for d in D:
        if c*d>0:
            plus1.append(c*d)
        elif c*d<0:
            minus1.append(-c*d)
        else:
            zero1+=1
minus0.sort()
minus1.sort()
plus0.sort()
plus1.sort()
def is_ok(ans):
    cnt=0
    if ans<0:
        i=len(plus1)
        for ab in minus0:
            while i and plus1[i-1]*ab>-ans:
                i-=1
            cnt+=len(plus1)-i
        i=len(plus0)
        for ab in plus0:
            while i and minus1[i-1]*ab>-ans:
                i-=1
            cnt+=len(minus1)-i
    elif ans==0:
        cnt+=len(plus0)*len(minus1)
        cnt+=len(plus1)*len(minus0)
    else:
        cnt+=len(plus0)*len(minus1)
        cnt+=len(plus1)*len(minus0)
        cnt+=zero0*(len(plus1)+len(minus1))+zero1*(len(plus0)+len(minus0))+zero0*zero1
        i=0
        for ab in minus0:
            while i<len(minus1) and minus1[i]*ab<ans:
                i+=1
            cnt+=i
        for ab in plus0:
            while i<len(plus1) and plus1[i]*ab<ans:
                i+=1
            cnt+=i
    return cnt<S
inf=1<<60
ans=Bisect_Int(-inf,inf,is_ok)
if ans==0:
    for kk in range(K):
        if A[kk]==0:
            k,l,m,n=kk,0,0,0
            break
    else:
        for ll in range(L):
            if B[ll]==0:
                k,l,m,n=0,ll,0,0
                break
        else:
            for mm in range(M):
                if C[mm]==0:
                    k,l,m,n=0,0,mm,0
                    break
            else:
                for nn in range(N):
                    if D[nn]==0:
                        k,l,m,n=0,0,0,nn
else:
    dct={}
    for k in range(K):
        for l in range(L):
            dct[A[k]*B[l]]=(k,l)
    for m in range(M):
        for n in range(N):
            cd=C[m]*D[n]
            if cd and ans%cd==0 and ans//cd in dct:
                k,l=dct[ans//cd]
                break
        else:
            continue
        break
print(ans)
print(" ".join(map(str,(A[k],B[l],C[m],D[n]))))
0