Writing Jutae's Personal Statement
Time limit1sMemory limit256 MB
Assign each story to at most one of three questions, with per-question caps and at least one story each, to maximize total fit score.
- Level
Medium7 of 10
- Topics
- Graph, Shortest path, Greedy
- Solved
- No attempts yet
Problem
Jutae has started writing a college application essay with three questions. Jutae has a wide range of school life stories, but learned that using too many stories can count against the essay. So Jutae decided to compute the fit between each story and each question, then pick which stories to use. Jutae needs a break after computing the fit scores, so choosing the stories is up to you. Find the largest total fit Jutae can get. Each question must contain at least one story, and no story may be used more than once.
Input
The first line contains the number of stories N (3 ≤ N ≤ 500). The second line contains the maximum number of stories that can go into each question, A, B, and C (1 ≤ A, B, C ≤ N), in that order. Each of the next N lines contains the fit a, b, and c (-10,000 ≤ a, b, c ≤ 10,000) of the i-th story with each question, in order. All input values are integers.
Output
Print the largest total fit Jutae can get.