IntermediateRating 1400
k-th Smallest in a Sorted Grid
Every row and every column of the n × n grid is sorted. Print the k-th smallest number (counting repeats).
Input
n and k, then n rows.
Output
One integer.
Sample 1
Input
3 8 1 5 9 10 11 13 12 13 15
Output
13
Sample 2
Input
1 1 -5
Output
-5
Output appears here