두 플레이어가 무한히 번갈아 두는 게임에서 신데렐라가 강제할 수 있는 최댓값을 구한다.
어려움9게임 이론그리디수학정렬아직 제출이 없습니다시간 제한2초메모리 제한512 MB
Is it a notorious coincidence with this problem?
Cinderella and her wicked Stepmother are playing the game. Cinderella has n non-negative integers \(a_1, a_2, \dots , a_n\) at first. There are two parameters A and B 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
Then Stepmother can choose B indices i_1,i_2,…,i_B, and set a_i_1,a_i_2,…,a_i_B to 0.
The game continues forever. Let M be the maximum value of a_1,a_2,…,a_n for all the time. Cinderella wants to maximize M, and Stepmother wants to minimize M.
Determine the value of M if both players play optimally.
The first line contains an integer T (1≤T≤105) indicating the number of test cases. For each test case:
The first line contains three integers n,A,B (1≤B≤n≤105,0≤A≤1012).
The second line contains n integers a_1,a_2,…,a_n (0≤a_i≤1012).
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}.