#C9731. Determine the Position of a New Stamp
Determine the Position of a New Stamp
Determine the Position of a New Stamp
You are given a collection of stamps represented as integer values. When a new stamp is purchased, its value is added to the collection. Your task is to determine the position of the new stamp after the collection is sorted in descending order. The position is 1-indexed.
In mathematical terms, if the collection of existing stamps is (S = {s_1, s_2, \dots, s_n}) and the new stamp has value (X), then after forming the set (S' = S \cup {X}) and sorting it in descending order, determine the smallest index (i) such that the (i)-th element equals (X).
inputFormat
The input is given via standard input and consists of multiple test cases. The first line contains a single integer (T) representing the number of test cases. For each test case, the input is described as follows:
- The first line of each test case contains a single integer (N), the number of stamps in the current collection.
- The second line contains (N) space-separated integers representing the values of the stamps.
- The third line contains a single integer (X), the value of the new stamp.
The input follows this format for all test cases.
outputFormat
For each test case, output a single integer representing the 1-indexed position of the new stamp in the collection after it has been inserted and sorted in descending order. Each result should be printed on a new line on the standard output.## sample
2
3
5 10 3
4
4
8 1 6 2
5
3
3
</p>