题目描述
Problem Description
Takahashi decided to improve his computational skills with "100 Million Square Calculation." This involves creating a table with $ N $ rows and $ N $ columns. For the $ i $-th row, the number $ a_i $ is written to the left of the leftmost cell, and for the $ j $-th column, the number $ b_j $ is written above the topmost cell. Takahashi calculates and fills in the value of $a_i \times b_j$ in the cell at the $ i $-th row and $ j $-th column.
Bored with the quick completion, Takahashi decided to sort the $ N^2 $ values he wrote in ascending order. Find the value that is at the $ K $-th position (starting from 1) in this sorted list.
Input Format
The input is given from the standard input in the following format:
$ N $ $ K $ $ a_1 $ $ a_2 $ .. $ a_N $ $ b_1 $ $ b_2 $ .. $ b_N $
- The first line contains the number of rows and columns of the table $ N $ ($1 \leq N \leq 30000$) and the position $ K $ ($1 \leq K \leq N^2$) in the sorted list to find, separated by spaces.
- The second line contains the numbers $ a_i $ ($1 \leq a_i \leq 10^9$) written to the left of the leftmost cell of each row $ i $ ($1 \leq i \leq N$), separated by spaces.
- The third line contains the numbers $ b_j $ ($1 \leq b_j \leq 10^9$) written above the topmost cell of each column $ j $ ($1 \leq j \leq N$), separated by spaces.
Output Format
Output to the standard output the value that is at the $ K $-th position (starting from 1) in the sorted list of the $ N^2 $ values written by Takahashi, followed by a newline.
Sample Input and Output
Sample Input #1
2 3
2 3
3 5
Sample Output #1
10
Sample Input #2
3 7
1 2 1
2 1 2
Sample Output #2
2
Sample Input #3
4 8
701687787 500872619 516391519 599949380
458299111 633119409 377269575 717229869
Sample Output #3
317112176525562171
Notes/Hints
Partial Points
This problem has partial points.
- Test cases worth 5 points satisfy $1 \leq N \leq 10$.
Sample Explanation 1
After sorting the values written by Takahashi in ascending order, we get $ 6, 9, 10, 15 $, and the 3rd smallest value is $ 10 $.
Sample Explanation 2
After sorting the values written by Takahashi in ascending order, we get $ 1, 1, 2, 2, 2, 2, 2, 4, 4 $, and the 7th smallest value is $ 2 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分