CF2209A.Flip Flops

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Flip Flops

OtterZ set up a battle with nn monsters in order to increase his combat power. Each monster has a combat power aia_i and OtterZ has a combat power of cc. He has kk flip flops and can perform the following operations:

  1. Kill an alive monster ii if aica_i \le c; then cc becomes c+aic + a_i.
  2. Throw a flip flop at an alive monster ii; the flip-flop will be broken and the monster will become angrier, then aia_i becomes ai+1a_i + 1.

Help OtterZ obtain the maximum possible cc after the battle.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains three integers nn, cc and kk (1n1001 \le n \le 100, 0c,k1090 \le c,k \le 10 ^ 9).

The second line contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (0ai1090\le a_i\le 10 ^ 9).

Output

For each test case, output an integer — the maximum possible combat power.

Note

In the first test,OtterZ found a strong monster and ran away, with combat power 1212.

In the sixth test, OtterZ participated in the battle:

  1. Throw 1010 flip flops to monster 22, the combat power of monster 22 turns to 1212.
  2. Throw 1010 flip flops to monster 11, the combat power of monster 11 turns to 1111.
  3. Kill monster 11, OtterZ's combat power turns to 2929.
  4. Throw 1010 flip flops to monster 55, the combat power of monster 55 turns to 1212.
  5. Kill monster 22, OtterZ's combat power turns to 4141.
  6. Kill monster 55, OtterZ's combat power turns to 5353.
  7. OtterZ runs away with combat power 5353.

Samples

10
1 12 23
21
1 8 4
5
1 3 4
16
3 6 3
14 9 11
5 9 2
20 16 18 16 11
5 18 30
1 2 93 84 2
7 29 13
2 9 38 4 7 1 6
10 9 2
8 1 8 11 17 3 14 16 20 10
10 192 109
1 9 20 9 829 3 87 1 283 7
10 1000000000 1000000000
19 1000000000 1 9 2 3 8 1 2 3
12
16
3
6
9
53
109
119
721
3000000048

在线编程 IDE

建议全屏模式获得最佳体验