#P17632. [ICPC 2019 Yinchuan R] Girls Band Party
[ICPC 2019 Yinchuan R] Girls Band Party
Problem Description
You are currently playing a game called "Garupa". In an event of the game, you are trying to get more event points. You have cards, each with its own name, color, and power. When you play the game, you can put five cards of different names into your deck. The base point of this event is the sum of the power of the cards in your deck. On top of that, the event publishes a color and five names as bonus attributes, which means that each time you have a card with a bonus color in the deck, you end up with a increase in event point. And each time you have a card with a bonus name in the deck, you will eventually get of the event point (bonus values are calculated by addition, and we round down when calculating the final event point). Please find the maximum event point you will eventually get.
Input Format
The first line is an integer , which is the number of test cases.
For each set of input data, input a positive integer in the first line to indicate the number of cards you have.
The next lines, the -th line input two strings , and a positive integer separated by spaces, indicating the name, color, and power of the -th card. The input data ensures that there are at least five cards with different names.
The next line input five strings representing the five bonus names. The input data guarantees that the bonus names are different.
The last line input a string representing a bonus color.
The input data ensures that all strings consist of only uppercase and lowercase letters and the max length of them is , and the sum of in all sets of input data does not exceed .
Output Format
For each set of data, output only one line of a positive integer, indicating the maximum number of bonus points that you will eventually get.
1
6
Saaya Power 45000
Kokoro Happy 45000
Kasumi Cool 45000
Rimi Power 45000
Aya Pure 45000
Aya Power 2000
Saaya Tae Kasumi Rimi Arisa
Power
382500