P6300 Repentance

Description

Daniel13265 has some small wooden sticks of the same original length. He randomly cuts each stick into two parts, making sure that the length of each part does not exceed $m$. Now he wants to connect the small sticks back to their original form, but he has lost some of the sticks, and he also forgot how many sticks he had at the beginning and what their original length was. So he plans to use the remaining small sticks to connect and form as many sticks of the same length as possible. Given the length of each remaining small stick segment, find (1) the maximum number of equal-length sticks that can be formed from the remaining segments, and (2) the minimum possible stick length when this maximum number is achieved.

Input Format

The input consists of $2$ lines. The first line contains two positive integers $n, m$, representing the number of remaining stick segments and the maximum possible length of a remaining segment. The second line contains $n$ positive integers separated by single spaces. The $i$-th integer $a_i$ represents the length of the $i$-th segment.

Output Format

Output one line with two integers: the maximum number of equal-length sticks that can be formed from the remaining segments, and the minimum possible stick length when this maximum is achieved.

Explanation/Hint

### Sample Explanation To form as many sticks of length $11$ as possible, you can connect the segments of lengths $2$ and $9$, and connect the segments of lengths $4$ and $7$. However, if you connect the segments of lengths $1$ and $8$, and connect the segments of lengths $2$ and $7$, you can form $2$ sticks of length $9$. It can be seen that the maximum number of equal-length sticks that can be formed is $2$. In this case, the stick length could be $9$, $10$, or $11$, and the smallest is $9$. ### Constraints **This problem uses bundled subtasks. You will get the full score of a subtask only if you pass all test points in that subtask.** | Subtask ID | $n\le$ | $m\le$ | Score | |:-:|:-:|:-:|:-:| | $1$ | $10$ | $10^5$ | $5$ | | $2$ | $10^3$ | $10^3$ | $10$ | | $3$ | $10^3$ | $10^5$ | $10$ | | $4$ | $10^5$ | $10$ | $5$ | | $5$ | $10^5$ | $10^3$ | $10$ | | $6$ | $10^5$ | $10^5$ | $60$ | For $100\%$ of the testdata, $2\le n, m\le 10^5$ and $1\le a_i\le m$. Translated by ChatGPT 5