結果
| 問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2020-09-06 22:10:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,810 bytes |
| 記録 | |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 81,820 KB |
| 実行使用メモリ | 238,980 KB |
| 最終ジャッジ日時 | 2024-12-27 18:19:29 |
| 合計ジャッジ時間 | 84,777 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 RE * 47 TLE * 22 |
ソースコード
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(J):
S=0
for u in U:
if u>0:
S+=Binary_Search_Small_Count(V,J//u,True)
elif u<0:
S+=Binary_Search_Big_Count(V,(-J-u-1)//u,True)
else:
if J>=0:
S+=len(V)
return S
def h(A,B,x):
G=set(B)
for a in A:
if x%a==0 and x//a in B:
return (a,x//a)
return None
#=================================================
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))+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)
Kazun