#abc234d. [abc234_d]Prefix K-th Max
[abc234_d]Prefix K-th Max
Problem Statement
Given are a permutation of and a positive integer .
For each , find the following.
- The -th greatest value among the first terms of .
Constraints
- is a permutation of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
For each , in this order, print the specified value in Problem Statement, separated by newlines.
Sample Input 1
3 2
1 2 3
Sample Output 1
1
2
- The -nd greatest value among the first terms of , , is .
- The -nd greatest value among the first terms of , , is .
Sample Input 2
11 5
3 7 2 5 11 6 1 9 8 10 4
Sample Output 2
2
3
3
5
6
7
7