#P6248. 准备战斗,选择你的英雄
准备战斗,选择你的英雄
Background
zjf was teased in the NOIP Junior preliminary round. He got pj 1= -> third prize in the preliminary round, left OI in anger, and got stuck in the swamp of the senior high school entrance exam. It is said that he became depressed because he played the game OW too much.
Problem Description
Currently, the game has heroes, and each match can send heroes into battle. The number of heroes that can actually be used will be less than . Assume simply that each hero’s contribution to the team can be represented by a positive integer . The team’s total power equals the sum of all heroes’ contributions. In particular, for specific pairs of heroes, if they appear together, the team’s total power increases by .
Note: Hero combinations can repeat; if they repeat, count them multiple times.
Input Format
The first line contains two integers and , representing the number of available heroes and the number of specific combinations.
The next lines each give the name of the -th hero first, then an integer .
The next lines each contain two strings , , and an integer , meaning that if heroes and appear together, the total power increases by .
Guaranteed: and are not the same hero.
Output Format
Output one integer, the maximum possible team power.
7 0
Sigma 10
Orisa 10
Mei 10
Reaper 10
Moira 10
Lucio 10
Doomfist 1
60
8 2
Pharah 5
Mercy 5
Reinhardt 10
DVA 10
SOLDIER:76 12
Torbjorn 5
Anna 8
Baptiste 10
Pharah Mercy 20
Anna Pharah 5
75
Hint
Sample 1 Explanation
We should choose the first heroes.
Sample 2 Explanation
We should choose Pharah, Mercy, Reinhardt, DVA, SOLDIER:76, Anna.
Constraints
For of the testdata, .
For of the testdata, , , , hero name length , and the character set includes uppercase letters, lowercase letters, digits, and colons (:). Each hero name is unique.
Translated by ChatGPT 5