問題一覧 > 通常問題

No.1361 [Zelkova 4th Tune *] Poem of QUADRUPLE-SEQUENCE

レベル : / AI推定難易度 : 2100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 31
作問者 : 👑 Kazun / テスター : 夕叢霧香(ゆうむらきりか)
お気に入りにしたユーザー ProblemId : 5168 / 自分の提出
問題文最終更新日: 2021-03-31 01:16:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 279 (Zelkova and Cherry) (順位表) の他の問題:

Note

The problems of yukicoder contest 279 (Zelkova and Cherry) are not sorted in order of difficulty. Therefore, we strongly recommend choosing which problems to attempt based on publicly available information such as the problem statements, the number of stars indicating difficulty, and the number of solvers.

Problem Statement

There are four sequences $\mathbb{A}=(A_w)_{w=1}^K, \mathbb{B}=(B_x)_{x=1}^L ,\mathbb{C}=(C_y)_{y=1}^M, \mathbb{D}=(D_z)_{z=1}^N$ of lengths $K,L,M,N$, respectively. From these four sequences, define the quadruple-indexed sequence $\mathbb{E}=(E_{w,x,y,z})_{w,x,y,z}$ by $E_{w,x,y,z}=A_w B_x C_y D_z$.

The sequence $\mathbb{E}$ has $KLMN$ elements in total. When these elements are sorted in ascending order, find the number $T$ that is the $S$-th from the smallest, and give one each of the elements $a,b,c,d$ of the sequences $\mathbb{A},\mathbb{B},\mathbb{C},\mathbb{D}$ that satisfy $T=abcd$.

Constraints

  • $1 \leq K,L,M,N \leq 600$
  • $1 \leq S \leq KLMN$
  • $-3 \times 10^4 \leq A_w,B_x,C_y,D_z \leq 3 \times 10^4$
  • All input values are integers.

Input

The input is given from standard input in the following format.
$K\ L\ M\ N\ S$
$A_1\ \dots A_K$
$B_1\ \dots B_L$
$C_1\ \dots C_M$
$D_1\ \dots D_N$

Output

When the $S$-th number of the quadruple sequence $\mathbb{E}$ sorted in ascending order is $T$, and the elements $a,b,c,d$ of $\mathbb{A},\mathbb{B},\mathbb{C},\mathbb{D}$ satisfy $T=abcd$, output them as follows.

$T$
$a\ b\ c\ d$
The second line must be space-separated, and do not forget the newline at the end. If there are multiple $a,b,c,d$ satisfying $T=abcd$, you may output any of them.

Sample

Sample 1
Input
1 1 2 3 4
-1
2
-3 4
-5 6 -7
Output
36
-1 2 -3 6

Sorting the 6 elements of $\mathbb{E}$ in ascending order gives $-48, -42, -30, 36, 40, 56$. The 4th smallest among them is $36$. To obtain the product $36$, there is the combination $36=(-1) \times 2 \times (-3) \times 6$.

Sample 2
Input
1 2 3 4 12
1
1 1
1 1 1
1 1 1 1
Output
1
1 1 1 1

$\mathbb{E}$ is a quadruple-indexed sequence consisting of 24 copies of $1$.

Sample 3
Input
8 8 8 8 2000
3 1 4 1 5 9 2 6
5 3 5 8 9 7 9 3
2 3 8 4 6 2 6 4
3 3 8 3 2 7 9 5
Output
288
2 3 6 8

There may be multiple combinations of elements $a,b,c,d$ of the sequences $\mathbb{A},\mathbb{B},\mathbb{C},\mathbb{D}$ satisfying $abcd=T$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。