結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー vwxyzvwxyz
提出日時 2023-12-01 01:48:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 2,895 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 19,476 KB
最終ジャッジ日時 2023-12-01 01:49:00
合計ジャッジ時間 15,066 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
18,068 KB
testcase_01 AC 37 ms
11,264 KB
testcase_02 AC 38 ms
11,264 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 37 ms
11,392 KB
testcase_07 WA -
testcase_08 AC 203 ms
11,648 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 119 ms
11,648 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 69 ms
11,392 KB
testcase_15 AC 314 ms
11,776 KB
testcase_16 AC 239 ms
11,520 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 1,041 ms
13,056 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 RE -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
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 #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

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()))
lst0=[]
for a in A:
    for b in B:
        lst0.append(a*b)
minus1,plus1,zero1=[],[],0
for c in C:
    for d in D:
        if c*d<0:
            minus1.append(c*d)
        elif c*d==0:
            zero1+=1
        else:
            plus1.append(c*d)
minus1.sort(reverse=True)
plus1.sort(reverse=True)
lst0.sort()
def is_ok(ans):
    cnt=0
    i=0
    for cd in minus1:
        while i<len(lst0) and lst0[i]*cd>=ans:
            i+=1
        cnt+=len(lst0)-i
        #cnt+=len(lst0)-Bisect_Int(0,len(lst0)+1,lambda i:i==0 or lst0[i-1]*cd>=ans)
        assert i==Bisect_Int(0,len(lst0)+1,lambda i:i==0 or lst0[i-1]*cd>=ans)
    if 0<ans:
        cnt+=len(lst0)*zero1
    i=0
    for cd in plus1:
        while i<len(lst0) and lst0[i]*cd<ans:
            i+=1
        cnt+=i
        #cnt+=Bisect_Int(0,len(lst0)+1,lambda i:i==0 or lst0[i-1]*cd<ans)
    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(A[k],B[l],C[m],D[n])
0