#C1734. Valid Insertion Positions for a New Coin
Valid Insertion Positions for a New Coin
Valid Insertion Positions for a New Coin
You are given a sorted list of distinct coin values and a new coin value. Your task is to determine the number of positions where the new coin can be inserted such that the ordering of the list remains sorted.
Since the coins are in strictly increasing order and the new coin can be inserted at the beginning, between any two coins, or at the end, the answer is always the number of coins plus one, i.e. if there are n coins then there are n+1 valid insertion positions.
Note: The input is read from standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line of input contains an integer T representing the number of test cases.
For each test case, the input consists of the following lines:
- An integer n indicating the number of coins.
- If n > 0, a line with n space-separated integers representing the coin values in sorted order.
- A line containing an integer representing the new coin value.
You must process all test cases.
outputFormat
For each test case, output a single line containing the number of valid insertion positions for the new coin.
## sample4
5
1 3 5 7 9
6
4
2 4 6 8
5
1
1
2
0
10
6
5
2
1
</p>