#P6230. Find the C-th Best Team

    ID: 19449 Type: Default 1000ms 256MiB

Find the C-th Best Team

Find the C-th Best Team

In this problem, two neighboring cities send a team of exactly KK contestants to participate in KK competitions every year. Each contestant takes part in all KK competitions. For each competition, the team’s score is determined by the highest score obtained by any team member in that competition. The total team score is the sum of the scores from all KK competitions.

A team is formed by selecting exactly KK candidates out of nn available candidates. Two teams are considered different if and only if they differ in at least one member. The teams are then ranked in descending order according to their total scores (the team with the highest score is ranked 1, the second highest is ranked 2, and so on). Your task is to find the total score of the CC-th best team.

The input begins with three integers nn, KK, and CC, where nn is the number of candidates, KK is both the number of competitions and the team size, and CC represents the rank of the team to retrieve (with C=1C = 1 being the best team). Each of the following nn lines contains KK integers, with the jj-th integer in the ii-th line representing the score of candidate ii in competition jj.

inputFormat

The first line contains three integers: nn (the number of candidates), KK (the number of competitions and the number of contestants in each team), and CC (the rank of the team to find, where C=1C = 1 is the best team).
Each of the next nn lines contains KK integers, where the jj-th integer is the score for that candidate in competition jj.

outputFormat

Output a single integer representing the total score of the CC-th best team.

sample

3 3 1
4 5 3
7 3 6
3 4 5
18