#P11849. Firing Decision

    ID: 13949 Type: Default 1000ms 256MiB

Firing Decision

Firing Decision

In Firing Decision, the CEO of Delicious Cake Co. has set n company objectives. Every employee is required to choose either 1 or 2 objectives (no other choices are allowed), and employees who choose exactly the same set of objectives are grouped together. Consequently, there are exactly n groups for those who choose one objective and \(\frac{n(n-1)}{2}\) groups for those who choose two, totaling \(\frac{n(n+1)}{2}\) groups.

For each objective \(i\) (\(1 \le i \le n\)), an AI assigns a weight \(w_i\). A group is represented by a binary sequence \(y_1,y_2,\dots,y_n\) where \(y_i=1\) if objective \(i\) is chosen and \(y_i=0\) otherwise. The Judgement Index of a group is defined by:

\( J = \frac{\sum_{i=1}^{n}w_i\times y_i}{\sum_{i=1}^{n} y_i}\ \)

The CEO ranks all the groups by their judgement index in descending order and plans to fire the employees of the groups that rank in the top k. Your task is to determine the k-th largest judgement index. Note that if two different groups have the same judgement index, they are counted separately in the ranking.

Example: For n = 3 and k = 4 with weights \(w_1 = 5, w_2 = -2, w_3 = 3\), the groups and their judgement indices are as follows:

\(y_1\) \(y_2\) \(y_3\) Judgement Index
0 0 1 \(\frac{3}{1} = 3\)
0 1 0 \(\frac{-2}{1} = -2\)
0 1 1 \(\frac{-2+3}{2} = \frac{1}{2}\)
1 0 0 \(\frac{5}{1} = 5\)
1 0 1 \(\frac{5+3}{2} = 4\)
1 1 0 \(\frac{5-2}{2} = \frac{3}{2}\)

After sorting in descending order, the judgement indices are: \(5, 4, 3, \frac{3}{2}, \frac{1}{2}, -2\). Thus, the 4th largest judgement index is \(\frac{3}{2}\). In the output, if the answer is an integer, print it directly; otherwise, print it as an irreducible fraction in the form "p/q" (without quotes).

inputFormat

The first line contains two integers n and k (1 ≤ n ≤ 2000, 1 ≤ k ≤ n(n+1)/2), representing the number of company objectives and the rank threshold respectively.

The second line contains n integers \(w_1, w_2, \dots, w_n\) (\(|w_i| \le 10^9\)) representing the weights of the objectives.

outputFormat

Output the k-th largest judgement index as an irreducible fraction. If the index is an integer, output it without a denominator.

sample

3 4
5 -2 3
3/2