Olympiads
Time limit2sMemory limit512 MB
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 contestants to compete in 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 and the contestants score , , and , then the scores for the team in the events are and the total score of the team is .
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 -th best team, where corresponds to the best team, to the second best team, and so on.
You are tasked with helping one of the cities find the expected total score of its -th best team, considering all the different -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 , , and , where is the total number of eligible contestants in a city, is the size of the team (), and is the index of the team we are interested in ( does not exceed the number of possible -member teams).
Each of the following lines contains non-negative integers, the expected scores of one eligible contestant in the events. No score is greater than .
Output
The only line should contain the total score of the -th best team.