#P2645. 斯诺克
斯诺克
Description
Xiao Ar and Xiao Be cannot remember so many snooker rules, so they invented a simpler set of rules.
In this problem, the playing rules are as follows:
- Ball values are the same as in snooker, i.e., .
- Xiao Ar will play turns, and Xiao Be will play turns. If a ball is potted, the player’s score increases by the ball’s value; if a turn results in a miss, the opponent gains points. Potted balls are not removed from the table.
Compute the score of the ongoing match up to now.
Input Format
The input has three lines. The first line contains two integers and , indicating that Xiao Ar played shots and Xiao Be played shots. There is a single space between and . It is not guaranteed that .
The second line contains space-separated integers, representing Xiao Ar’s consecutive shots.
The third line contains space-separated integers, representing Xiao Be’s consecutive shots.
In the second and third lines: integers from to indicate the value of the ball potted, and indicates a miss.
Output Format
Output a single line with two integers, representing the scores of Xiao Ar and Xiao Be, respectively.
4 3
1 7 1 6
1 7 1
15 9
Hint
Sample Explanation:
- Xiao Ar potted, in order, a red, black, red, and pink ball, scoring points ().
- Xiao Be potted, in order, a red, black, and red ball, scoring points ().
Constraints: For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号