#K71947. Taco Challenge Score Calculation

    ID: 33644 Type: Default 1000ms 256MiB

Taco Challenge Score Calculation

Taco Challenge Score Calculation

In the Taco Challenge, each participant competes in several rounds. In each round, participants attempt tasks with different difficulty values. Their performance in each round is recorded as a character: 'S' (Success) or 'F' (Failure). For each success, a participant gains points equal to the difficulty value of that round. For each failure, they lose (\lfloor \text{difficulty}/2 \rfloor) points. Given the number of participants and their respective performance strings paired with a list of difficulty values, calculate the total score for each participant.

For example, if a participant's record is "SFSF" with difficulties "4 8 4 8", the participant earns 4 points in the first round, loses 4 points (8//2) in the second round, earns 4 points in the third round, and loses 4 points in the fourth round, yielding a total score of 0.

inputFormat

Input is given via standard input (stdin). The first line contains an integer (N) representing the number of participants. Each of the next (N) lines contains a performance string followed by space-separated integers. The performance string consists only of the characters 'S' and 'F' and its length equals the number of rounds for that participant. The subsequent integers represent the difficulty values for each round in order.

outputFormat

Output the total score for each participant on a separate line to standard output (stdout).## sample

0