GFSSOC '17 J5 - Choosing Extracurriculars

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 31M

Authors:
Problem type

What makes a great application? Extracurriculars. Throughout his 4 years in high school, Ace has participated in N (1 \le N \le 100\,000) extracurriculars. Unfortunately, the application only allows him to talk about four of them. Thus, Ace chooses to talk about one extracurricular per grade. In every club, for every year he has participated in it, he is given an excellency score for his enthusiasm (0 \le score \le 1000). If Ace did not participate in that club for a grade, the score value will be -1 (Ace is guaranteed to have participated in the club for at least 1 year). Ace cannot use one club for more than one grade (each grade has to be represented by a unique club). Find the maximum combined excellency score for the four years so that Ace can show the most of his extracurriculars.

Input Specification

First line: integer N, the number of extracurriculars Ace has done.

Next N lines: four integers a, b, c, and d. a is his excellency score in that club in grade 9, b for grade 10, c for grade 11, and d for grade 12.

Output Specification

The maximum total excellency Ace can achieve.

Sample Input 1

4
7 6 8 10
4 10 10 5
9 4 4 4
2 1 2 1

Sample Output 1

31

Explanation

For grade 9, Ace chooses club #3 (excellency = 9), for grade 10, Ace chooses club #2 (excellency = 10), for grade 11, Ace chooses club #4 (excellency = 2) and for grade 12, Ace chooses club #1 (excellency = 10) for a grand total of 31 excellency points.

Sample Input 2

6
5 5 4 5
8 6 6 6
7 0 -1 -1
-1 -1 -1 5
8 8 -1 8
10 0 0 4

Sample Output 2

29

Sample Input 3

2
8 8 6 6
6 8 6 6

Sample Output 3

16

Comments


  • 21
    alexzhang  commented on Sept. 2, 2018, 6:54 a.m. edited

    I wonder what school's gonna reject him, given his 100000 extracurriculars