Double Up 2
Time limit2sMemory limit1024 MB
Each array element can be doubled mod M. Find the largest number of equal values reachable and the fewest doublings needed to make that many equal.
- Level
Medium7 of 10
- Topics
- Graph, Dynamic programming, Number theory, Hash map
- Solved
- No attempts yet
Problem
Dalgu has an array of integers and an integer . Dalgu can perform the following operation on this array as many times as he wants.
- Choose an index with . Replace with .
After Dalgu finishes all operations, let be the number that appears most often in the array. Find the maximum possible number of occurrences of , and the minimum number of operations needed to reach an array state where this maximum is achieved.
Input
The first line contains and , separated by a space. ()
The second line contains integers , separated by spaces. ()
Output
Print the maximum possible number of occurrences of the most frequent value, and the minimum number of operations needed to reach such an array, separated by a space.