Codeforces Round 939 (Div. 2) |
---|
Finished |
Nene invented a new game based on an increasing sequence of integers $$$a_1, a_2, \ldots, a_k$$$.
In this game, initially $$$n$$$ players are lined up in a row. In each of the rounds of this game, the following happens:
Once no one is kicked out of the game in some round, all the players that are still in the game are declared as winners.
For example, consider the game with $$$a=[3, 5]$$$ and $$$n=5$$$ players. Let the players be named player A, player B, $$$\ldots$$$, player E in the order they are lined up initially. Then,
Nene has not yet decided how many people would join the game initially. Nene gave you $$$q$$$ integers $$$n_1, n_2, \ldots, n_q$$$ and you should answer the following question for each $$$1 \le i \le q$$$ independently:
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 250$$$). The description of test cases follows.
The first line case contains two integers $$$k$$$ and $$$q$$$ ($$$1 \le k, q \le 100$$$) — the length of the sequence $$$a$$$ and the number of values $$$n_i$$$ you should solve this problem for.
The second line contains $$$k$$$ integers $$$a_1,a_2,\ldots,a_k$$$ ($$$1\leq a_1<a_2<\ldots<a_k\leq 100$$$) — the sequence $$$a$$$.
The third line contains $$$q$$$ integers $$$n_1,n_2,\ldots,n_q$$$ ($$$1\leq n_i \leq 100$$$).
For each test case, output $$$q$$$ integers: the $$$i$$$-th ($$$1\le i \le q$$$) of them should be the number of players declared as winners if initially $$$n_i$$$ players join the game.
62 13 555 32 4 6 7 91 3 55 43 4 5 6 71 2 3 42 369 961 10 1001 1100503 310 20 301 10 100
2 1 1 1 1 2 2 2 1 10 68 50 1 9 9
The first test case was explained in the statement.
In the second test case, when $$$n=1$$$, the only player stays in the game in the first round. After that, the game ends and the only player is declared as a winner.
Name |
---|