Woburn Challenge 2017-18 Round 1 - Senior Division

Problem 1: On the Rocks

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 ≤ N ≤ 8) stones in play, with the i-th of them at a distance of Ai (0 ≤ Ai ≤ 370) cm away from the "button" (the centre of the scoring ring). Meanwhile, Team B has M (0 ≤ M ≤ 8) stones, with the i-th of them at a distance of Bi (0 ≤ Bi ≤ 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 Format

The first line of input consists of two space-separated integers, N and M.
The next line consists of integers, A1..N.
The next line consists of integers, B1..M.

Output Format

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 3rd one), so they'll be the team scoring some points. In particular, their 1st and 3rd stones will count for 1 point each. On the other hand, Team B's 2nd and 4th stones won't count for any points, as they're further from the button than Team A's 2nd stone is.

All Submissions
Best Solutions


Point Value: 7 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: Jan 26, 2018
Author: SourSpinach

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...