L-th K-th number
Time limit2sMemory limit512 MB
Given N cards, take the K-th smallest value of every contiguous block of length at least K, then report the L-th smallest of all those values.
- Level
Hard9 of 10
- Topics
- Binary search, Array, Prefix sum, Combinatorics
- Solved
- No attempts yet
Problem
cards lie in a row. The -th card from the left () has the integer written on it.
You play the following game with these cards. Choose a block of or more consecutive cards, then do this:
- Lay the chosen cards out from the left in increasing order of the integers written on them.
- Write down on paper the integer on the -th card from the left.
- Put every chosen card back where it was.
You do this once for every block of or more consecutive cards. That is, for every pair with and , you write down the -th smallest integer among .
Sort the integers you wrote down in increasing order. The -th of them, counting from the left, is your score in this game. Find the score.
Input
The input is given from standard input in the following format.
N K L
a_1 a_2 ... a_N
Output
Print the score on a single line.
Constraints
- The number of integers written on the paper is at least .