#P8088. 『JROI-5』Autumn
『JROI-5』Autumn
Background
Thanks to
Problem Description
This problem has a large input size. It is recommended to use a fast input method. You may refer to the contest announcement board.
You are given sequences, each with elements. The -th element of the -th sequence is the positive integer .
Each time, you may choose and , and swap and . You can perform at most swaps.
Define as the -th largest element in the -th sequence.
Minimize (i.e., the maximum among ).
Input Format
The first line contains two positive integers .
The next lines each contain positive integers, representing the sequences.
The last line contains two positive integers .
Output Format
Output one number: the minimized value of .
5 5
1 2 3 4 5
6 7 8 9 10
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
2 1
8
5 5
1 2 3 4 5
6 7 8 9 10
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
2 2
7
见附件
见附件
Hint
For Sample 1, swap and . It can be proven that there is no better strategy.
For of the testdata, , .
For another of the testdata, all numbers are equal.
For another of the testdata, , , , .
For of the testdata, , , , 。
Translated by ChatGPT 5