Interesting Game

두 플레이어가 무한히 번갈아 두는 게임에서 신데렐라가 강제할 수 있는 최댓값을 구한다.

어려움9게임 이론그리디수학정렬아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Is it a notorious coincidence with this problem?

Cinderella and her wicked Stepmother are playing the game. Cinderella has nn non-negative integers \(a_1, a_2, \dots , a_n\) at first. There are two parameters AA and BB  for this game.

Cinderella and Stepmother take turns playing, starting with Cinderella. One each turn, Cinderella can replace the sequence \(a_1, a_2, \dots, a_n\) by a new integer sequence \(a'_1, a'_2, \dots , a'_n\) such that

  •  \(\displaystyle a'_1 \ge a_1, \dots a'_n \ge a_n\)
  • \(\displaystyle\sum_{i=1}^{n}{a'_i} \le \sum_{i=1}^{n}{a_i} + A\)

Then Stepmother can choose BB indices i_1,i_2,,i_Bi\_1, i\_2, \dots , i\_B, and set a_i_1,a_i_2,,a_i_Ba\_{i\_1}, a\_{i\_2}, \dots , a\_{i\_B} to 0.

The game continues forever. Let MM be the maximum value of a_1,a_2,,a_na\_1, a\_2, \dots , a\_n for all the time. Cinderella wants to maximize MM, and Stepmother wants to minimize MM.

Determine the value of MM if both players play optimally.

입력

The first line contains an integer TT (1T1051 \le T \le 10^5) indicating the number of test cases. For each test case:

The first line contains three integers n,A,Bn, A, B (1Bn105,0A10121 \le B \le n \le 10^5, 0 \le A \le 10^{12}).

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \dots , a\_n (0a_i10120 \le a\_i \le 10^{12}).

It is guaranteed that \(\sum{n} \le 5 \times 10^5\).

출력

For each test case, output a line containing one integer: the answer.

힌트

A possible game process for the first test case:

{1, 2, 3} → {3, 4, 4} → {3, 4, 0} → {6, 6, 0} → {6, 0, 0} → {11, 0, 0}.