Under construction

Still being built. Things may change

Olympiads

Time limit2sMemory limit512 MB

Summary
Given N contestants with scores in K events, find the total score of the C-th best K-member team, where a team scores the per-event maximum over its members.
Level

Hard8 of 10

Topics
Binary search, Dynamic programming, Combinatorics, Bit manipulation
Solved
No attempts yet

Problem

Two neighbouring cities send each year a team of KK contestants to compete in KK different events. Each contestant participates in all the events. The score of a team in an event is the highest score earned by any of that team's contestants in that event. The total score of a team is the sum of the scores of the team over all events. For example, if K=3K = 3 and the contestants score (4,5,3)(4, 5, 3), (7,3,6)(7, 3, 6), and (3,4,5)(3, 4, 5), then the scores for the team in the events are (7,5,6)(7, 5, 6) and the total score of the team is 1818.

Each city has a set of eligible contestants it can send to the competition. The cities argue about which city has the best team and also about which city has the CC-th best team, where C=1C = 1 corresponds to the best team, C=2C = 2 to the second best team, and so on.

You are tasked with helping one of the cities find the expected total score of its CC-th best team, considering all the different KK-member teams it could compose from its eligible contestants. Two teams are considered different if at least one contestant differs.

Input

The first line contains the integers NN, KK, and CC, where NN is the total number of eligible contestants in a city, KK is the size of the team (K≤NK \le N), and CC is the index of the team we are interested in (CC does not exceed the number of possible KK-member teams).

Each of the following NN lines contains KK non-negative integers, the expected scores of one eligible contestant in the KK events. No score is greater than 10610^6.

Output

The only line should contain the total score of the CC-th best team.

Examples1

  1. Example 1

    Input
    5 4 4
    7 0 4 9
    3 0 8 4
    1 1 3 7
    5 1 3 4
    4 2 2 9
    
    Expected output
    24