Homeric Epics

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

In Homeric Epics there are nn different words numbered from 11 to nn. The ii-th word appears w_iw\_i times in the text. Allison wants to substitute the ii-th word with a kk-ary string s_is\_i, satisfying the following constraint: for any 1i,jn1 \le i,j \le niji \ne js_is\_i is not the prefix of s_js\_j.

Allison wants to know how to choose s_is\_i so that the resulting text has minimum length. Under the assumption that the total length of the text is minimal, Allison wants to know what is the shortest possible length of the longest s_is\_i.

A string is called a kk-ary string if and only if its characters are in 0,1,,k1\\{0, 1, \dots, k-1\\}.

A string s_1s\_1 is said to be a prefix of s_2s\_2 if and only if there exists 1tm1 \le t \le m such that s_1=s_2\[1t]s\_1 = s\_2\[1 \dots t] where mm is the length of s_2s\_2 and s_2\[1t]s\_2\[1 \dots t] represents the substring of s_2s\_2 formed by the first tt characters.

입력

The first line of the input file contains two integers n,kn,k separated by one space, denoting there are nn words in total and we need to substitute the words with a kk-ary string.

In the following nn lines, the (i+1)(i+1)-th line has a nonnegative integer w_iw\_i denoting the number of times the ii-th word has occurred.

출력

The output consists of two lines. The first line is an integer denoting the minimum length of the Homeric Epics after substitution. The second line is an integer denoting the minimum length of the longest string s_is\_i given the total length is minimum.

제한

  • 3n100,0003 ≤ n ≤ 100\\,000
  • 2k92 ≤ k ≤ 9
  • 0<w_i10110 < w\_i \le 10^{11}