I Am a Great Superstar K
Time limit1sMemory limit128 MB
Given N contestants' scores in M genres (each genre's scores listed sorted), pick K contestant-genre assignments (one genre per chosen contestant) maximizing total score, requiring a min-cost/max-flow or matroid intersection style greedy insight.
- Level
Hard8 of 10
- Topics
- Greedy, Graph, Dynamic programming
- Solved
- No attempts yet
Problem
Sanggeun directs the singing competition "I Am a Great Superstar K". He wants to choose finalists as follows.
There are N participants in the preliminary round, and each participant auditioned in M different genres. The judges assigned a real-valued score for every participant in every genre.
Exactly K participants can advance to the final round. Each finalist may sing exactly one genre in the final, and Sanggeun chooses that genre. A participant cannot sing multiple genres, but multiple participants may sing the same genre.
Given every participant's score in every genre, choose the finalists and their genres so that the total score is as large as possible.
Input
The first line contains N, M, and K. (1 <= M <= 100, 1 <= K <= N <= 100)
Each of the next M lines gives the participants' scores for one genre. A line contains N pairs (i, s), where i is a participant number and s is that participant's score in the genre. The pairs are given in non-increasing order of score. Participant numbers are from 1 to N.
Every participant appears exactly once on each of these lines.
Output
Print the maximum possible total score of the finalists, rounded to one digit after the decimal point.