#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., 171\sim 7.
  • Xiao Ar will play nn turns, and Xiao Be will play mm 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 44 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 nn and mm, indicating that Xiao Ar played nn shots and Xiao Be played mm shots. There is a single space between nn and mm. It is not guaranteed that n1mnn-1 \le m \le n.

The second line contains nn space-separated integers, representing Xiao Ar’s nn consecutive shots.

The third line contains mm space-separated integers, representing Xiao Be’s mm consecutive shots.

In the second and third lines: integers from 11 to 77 indicate the value of the ball potted, and 00 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 1515 points (1+7+1+6=151+7+1+6=15).
  • Xiao Be potted, in order, a red, black, and red ball, scoring 99 points (1+7+1=91+7+1=9).

Constraints: For 100%100\% of the testdata, 0n,m100, 0ai,bi70\le n,m\le 100,\ 0\le a_i,b_i\le 7.

Translated by ChatGPT 5