LCC '23 Contest 4 J3 - Engineering Room

View as PDF

Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

This year, so many contestants signed up for the CCC that the ICS classrooms were completely filled! Thus, to accomodate everyone, Josh and some of his classmates were moved to the Engineering Room (118E) to write the contest.

Unfortunately, Josh barely practiced for the CCC, and he knows that he has no chance of obtaining a good score!

Thankfully, upon entering and looking around the Engineering Room, Josh realizes that he can use the seating arrangement of 3 tables of 8 to his advantage: Josh devises a plan to cheat off the screens of his classmates!

Attached below is a diagram of the TEJ classroom.

From each seat, there are some other seats where their screens are within its field of view. Specifically, anyone sitting at a table (A, B, or C) can see any of the other 7 seats at the table's screens. Additionally, those sitting on the boundary of where two tables meet can also see the two seats behind them. These are drawn in purple in the diagram.

There are 24 people in the room in total, including Josh. The ith person has a coding skill of v_i (0 \le v_i \le 100). Josh's skill is 0, but for every person i whose screens he can see, he can cheat off their screen and his own coding skill level increases by v_i.

Some people have already taken a seat, but Josh and some others have not picked seats yet.

Josh wants to know what the maximum v_i he can achieve is amongst all of possible seating arrangements.

Constraints

0 \le v_i \le 100

Input Specifications

The input will consist of 23 lines, each representing one of his classmates.

Each line will be either of the form s v or s v p.

s is the name of one of Josh's classmates (no longer than 15 characters), and v is an integer representing v_i.

If there is a p parameter, it will be a string consisting of one letter (A, B, or C) and one integer from 1 to 8, which represents the seat that this person has sat down at, as shown on the diagram.

Output Specifications

Amongst all the people who have not sat down and Josh himself, calculate the maximum v_i that Josh can attain throughout all possible seatings.

Output this integer on its own line.

Sample Input 1

joshanahitadoshita 94
joshathan 34 C7
joshourangutan 75
joshalekseimitri 52 B7
joshishwajeetswapriyaditya 20 A1
jay-el-pockalypse 33 C6
josholessandrogiuseppina 27
joshinderella 44 B4
frank 100
joshalegrabov 92 B2
joshallacraguetta 17 A5
joshamseulgug 25 C2
joshathanatthew 38 A8
josh-terminator-3000 52 C8
joshatotheta 66 B3
josulius-caesar 86 C5
joshuette 64
joshanne 39 A3
joshabdulahita 21
joshiah 9 B8
joshorbarlomew 45
josharutobakuyamiotanna 46 C4
josh-mersenne-twister 30 A7

Sample Output 1

487

Sample Explanation 1

A possible solution would be for Josh to sit at C1, where he can see joshallacraguette, joshamseulgug, josharutobakuyamiotanna, josulius-caesar, jay-el-pockalypse, joshathan, and josh-terminator-3000. Additionally, one such arrangement where Josh's coding skill is maximized is when joshanahitadoshita sits at C3 and frank sits at A6.


Comments

There are no comments at the moment.