#C5154. K-th Longest String
K-th Longest String
K-th Longest String
Given a list of strings and an integer \(k\), your task is to output the \(k\)-th longest string. The strings should be sorted in descending order by their lengths. In case multiple strings have the same length, maintain their relative order from the input.
The input is provided via stdin
and the result must be printed to stdout
.
Note: The \(k\)-th longest string is the string at the \(k\)-th position (1-indexed) of the sorted list.
inputFormat
The first line of input contains an integer \(n\), the number of strings. The following \(n\) lines each contain a single string. The last line contains an integer \(k\).
outputFormat
Output a single line containing the \(k\)-th longest string after sorting.
## sample5
apple
banana
kiwi
watermelon
grape
2
banana