#P8088. Minimize Maximum k-th Largest Element

    ID: 21271 Type: Default 1000ms 256MiB

Minimize Maximum k-th Largest Element

Minimize Maximum k-th Largest Element

Given nn sequences each of length mm. The jj-th element of the ii-th sequence is a positive integer ai,ja_{i,j}. You are allowed to perform at most xx swap operations. In each swap, you can choose any two positions (i1,j1)(i_1,j_1) and (i2,j2)(i_2,j_2) and swap ai1,j1a_{i_1,j_1} with ai2,j2a_{i_2,j_2}.

For the ii-th sequence, let did_i denote its kk-th largest element. Your task is to minimize ( \max_{1 \le i \le n} d_i ).

Note: Because the input size can be large, it is recommended to use fast input methods. For example, refer to the contest bulletin for details.

inputFormat

The first line contains four space-separated integers nn, mm, kk, and xx, where nn is the number of sequences, mm is the number of elements per sequence, kk is the order for the k-th largest element, and xx is the maximum number of swap operations allowed. Each of the next nn lines contains mm positive integers representing the sequence ai,1,ai,2,,ai,ma_{i,1}, a_{i,2}, \ldots, a_{i,m}.

outputFormat

Output a single integer -- the minimized value of ( \max_{1 \le i \le n} d_i ) that can be achieved after at most xx swap operations.

sample

2 3 2 1
1 10 5
2 3 8
5