Array Sum
InterviewTime limit5sMemory limit512 MB
Reorder two arrays to make some sum value repeat as often as possible; report the maximum repeat count and the largest such sum.
Problem
You are given an array and an array , each of size .
You can shuffle the elements of and the elements of into any order you like. After shuffling, build the array by .
Let be the number that appears most often in , and let be how many times it appears. Build so that is as large as possible. If several ways of building reach the same largest , pick the one whose is largest.
Input
The first line contains the array size ().
The second line contains the elements of , and the third line contains the elements of , separated by spaces.
Every element of both arrays is an integer that is at least and less than .
Output
Print and on one line, separated by a space.