CF1772G.Gaining Rating

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Monocarp is playing chess on one popular website. He has nn opponents he can play with. The ii -th opponent has rating equal to aia_i . Monocarp's initial rating is xx . Monocarp wants to raise his rating to the value yy ( y>xy > x ).

When Monocarp is playing against one of the opponents, he will win if his current rating is bigger or equal to the opponent's rating. If Monocarp wins, his rating is increased by 11 , otherwise it is decreased by 11 . The rating of his opponent does not change.

Monocarp wants to gain rating yy playing as few games as possible. But he can't just grind it, playing against weak opponents. The website has a rule that you should play against all opponents as evenly as possible. Speaking formally, if Monocarp wants to play against an opponent ii , there should be no other opponent jj such that Monocarp has played more games against ii than against jj .

Calculate the minimum possible number of games Monocarp needs to gain rating yy or say it's impossible. Note that ratings of Monocarp's opponents don't change, while Monocarp's rating does change.

输入格式

The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

The first line of each test case contains three integers nn , xx and yy ( 1n21051 \le n \le 2 \cdot 10^5 ; 1x<y10121 \le x < y \le 10^{12} ) — the number of Monocarp's opponents, his initial and desired ratings.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai10121 \le a_i \le 10^{12} ) — ratings of Monocarp's opponents.

Additional constraint on the input: the total sum of nn over all tt test cases doesn't exceed 21052 \cdot 10^5 .

输出格式

For each test case, print a single integer — the minimum number of games Monocarp needs to play to gain rating yy , or 1-1 if it's impossible.

输入输出样例

  • 输入#1

    3
    7 2 10
    3 1 9 2 5 20 8
    7 1 10
    3 1 9 2 5 20 8
    5 10 12
    100 1 200 11 300

    输出#1

    20
    -1
    2

说明/提示

In the first test case, Monocarp can use the following strategy:

  1. Monocarp plays against the 22 -nd opponent to increase rating ( 232 \to 3 );
  2. Monocarp plays against the 11 -st opponent to increase rating ( 343 \to 4 );
  3. Monocarp plays against the 44 -th opponent to increase rating ( 454 \to 5 );
  4. Monocarp plays against the 55 -th opponent to increase rating ( 565 \to 6 );
  5. Now Monocarp have to play with remaining three opponents. So, he will lose 33 times and get rating 33 ( 65436 \to 5 \to 4 \to 3 );
  6. After that, Monocarp will repeat steps 1-5 again. After 1414 games, he has played twice with each opponent and get final rating 44 .
  7. Monocarp plays against the 11 -st opponent to increase rating ( 454 \to 5 );
  8. Monocarp plays against the 22 -nd opponent to increase rating ( 565 \to 6 );
  9. Monocarp plays against the 44 -th opponent to increase rating ( 676 \to 7 );
  10. Monocarp plays against the 55 -th opponent to increase rating ( 787 \to 8 );
  11. Monocarp plays against the 77 -th opponent to increase rating ( 898 \to 9 );
  12. Monocarp plays against the 33 -rd opponent to increase rating ( 9109 \to 10 );

In total, Monocarp, played twice against the 66 -th opponent and three times against other opponents and got rating 1010 in 14+6=2014 + 6 = 20 games.In the second test case, it can be proven that whichever games Monocarp plays, he can't get his rating higher than 44 .

首页