WC '17 Contest 1 S1 - On the Rocks

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Woburn Challenge 2017-18 Round 1 - Senior Division

Two teams have just finished playing a riveting round of Canada's national sport, curling, and it's time to tally up their scores! Team A has N (0 \le N \le 8) stones in play, with the i^{th} of them at a distance of A_i (0 \le A_i \le 370) cm away from the "button" (the centre of the scoring ring). Meanwhile, Team B has M (0 \le M \le 8) stones, with the i^{th} of them at a distance of B_i (0 \le B_i \le 370) cm away from the button. No two stones are equidistant from the button.

If there are no stones in play at all, neither team will score any points. Otherwise, only the single team which owns the closest stone to the button will score points. That team will score 1 point for each of their stones which is closer to the button than all of the other team's stones are. If the other team doesn't even have any stones in play, then each of the scoring team's stones counts for a point.

Please help tally up the two teams' final scores! Note that at least one of these two scores must be equal to 0.

Subtasks

In test cases worth 3/13 of the points, N = 1 and M = 1.

Input Specification

The first line of input consists of two space-separated integers, N and M.
The next line consists of integers, A_{1 \dots N}.
The next line consists of integers, B_{1 \dots M}.

Output Specification

Output two space-separated integers, the number of points scored by Teams A and B respectively.

Sample Input

2 4
205 44
33 146 14 45

Sample Output

0 2

Sample Explanation

Team B owns the closest stone to the button (their 3^{rd} one), so they'll be the team scoring some points. In particular, their 1^{st} and 3^{rd} stones will count for 1 point each. On the other hand, Team B's 2^{nd} and 4^{th} stones won't count for any points, as they're further from the button than Team A's 2^{nd} stone is.


Comments

There are no comments at the moment.