#P6300. 悔改

    ID: 7013 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2020O2优化枚举快速傅里叶变换 FFT快速数论变换 NTT

悔改

Problem 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 mm.

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 22 lines.

The first line contains two positive integers n,mn, m, representing the number of remaining stick segments and the maximum possible length of a remaining segment.

The second line contains nn positive integers separated by single spaces. The ii-th integer aia_i represents the length of the ii-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.

7 10
1 1 2 4 7 8 9

2 9

Hint

Sample Explanation

To form as many sticks of length 1111 as possible, you can connect the segments of lengths 22 and 99, and connect the segments of lengths 44 and 77. However, if you connect the segments of lengths 11 and 88, and connect the segments of lengths 22 and 77, you can form 22 sticks of length 99.

It can be seen that the maximum number of equal-length sticks that can be formed is 22. In this case, the stick length could be 99, 1010, or 1111, and the smallest is 99.

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 nn\le mm\le Score
11 1010 10510^5 55
22 10310^3 10310^3 1010
33 10510^5
44 10510^5 1010 55
55 10310^3 1010
66 10510^5 6060

For 100%100\% of the testdata, 2n,m1052\le n, m\le 10^5 and 1aim1\le a_i\le m.

Translated by ChatGPT 5