#P8088. 『JROI-5』Autumn

    ID: 9176 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>贪心二分2022O2优化排序洛谷月赛

『JROI-5』Autumn

Background

Thanks to

/user/353688
ing an approach better than the standard solution.

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 nn sequences, each with mm elements. The jj-th element of the ii-th sequence is the positive integer ai,ja_{i,j}.

Each time, you may choose (i1,j1)(i_1, j_1) and (i2,j2)(i_2, j_2), and swap ai1,j1a_{i_1,j_1} and ai2,j2a_{i_2,j_2}. You can perform at most xx swaps.

Define did_i as the kk-th largest element in the ii-th sequence.

Minimize maxi=1n{di}\max\limits_{i=1}^n \{d_i\} (i.e., the maximum among d1,d2,,dnd_1, d_2, \cdots, d_n).

Input Format

The first line contains two positive integers n,mn, m.

The next nn lines each contain mm positive integers, representing the sequences.

The last line contains two positive integers k,xk, x.

Output Format

Output one number: the minimized value of maxi=1n{di}\max\limits_{i=1}^n \{d_i\}.

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 a2,5a_{2,5} and a1,5a_{1,5}. It can be proven that there is no better strategy.


For 30%30\% of the testdata, x=106x = 10^6, 1km1 \leq k \leq m.

For another 10%10\% of the testdata, all numbers are equal.

For another 30%30\% of the testdata, 1n,m2×1031 \leq n, m \leq 2 \times 10^3, 1km1 \leq k \leq m, ai,j106a_{i,j} \leq 10^6, 0xn×m0 \leq x \leq n \times m.

For 100%100\% of the testdata, 1n,m2×1031 \leq n, m \leq 2 \times 10^3, 1km1 \leq k \leq m, 1ai,j10181 \leq a_{i,j} \leq 10^{18}, 0xn×m0 \leq x \leq n \times m

Translated by ChatGPT 5