P26519 [AtCoder] LthKthNumber
省选
题目描述

Problem Description

There are $ N $ cards arranged in a row. The $ i $-th card from the left ($1 \leq i \leq N$) has an integer $ a_i $ written on it.

JOI is playing a game using these cards. He selects a sequence of consecutive cards of at least $ K $ cards and performs the following operations:

  • Arrange the selected cards in ascending order of the integers written on them.
  • Write down the integer on the $ K $-th card from the left in the sorted sequence.
  • Return all selected cards to their original positions.

This operation is performed on all possible sequences of consecutive cards of at least $ K $ cards. That is, for all pairs $ (l, r) $ such that $1 \leq l \leq r \leq N$ and $K \leq r - l + 1$, the $ K $-th smallest integer among $ a_l, a_{l+1}, ..., a_r $ is written down.

The written integers are then arranged in ascending order. The $ L $-th integer in this sorted list is JOI's score in this game. Determine JOI's score.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ L $ $ a_1 $ $ a_2 $ $ ... $ $ a_N $

Output Format

Output JOI's score in one line.

Sample Input and Output

Sample Input #1

4 3 2
4 3 1 2

Sample Output #1

3

Sample Input #2

5 3 3
1 5 2 2 4

Sample Output #2

4

Sample Input #3

6 2 9
1 5 3 4 2 4

Sample Output #3

4

Sample Input #4

6 2 8
1 5 3 4 2 4

Sample Output #4

3

Notes/Hints

Constraints

  • $1 \leq N \leq 200000$
  • $1 \leq K \leq N$
  • $1 \leq a_i \leq N$
  • $1 \leq L$
  • JOI writes down at least $ L $ integers.

Subtask 1 [6 points]

  • $N \leq 100$

Subtask 2 [33 points]

  • $N \leq 4000$

Subtask 3 [61 points]

  • No additional constraints.

Sample Explanation 1

The pairs $ (l, r) $ that satisfy $1 \leq l \leq r \leq N (= 4)$ and $K (= 3) \leq r - l + 1$ are $ (1, 3), (1, 4), (2, 4) $. For these pairs, the $ 3 $-th smallest integer among $ a_l, a_{l+1}, ..., a_r $ are $ 4, 3, 3 $ respectively. The $ L (= 2) $-th smallest integer among these is $ 3 $, so JOI's score is $ 3 $. Note that duplicates are counted when determining the $ L $-th smallest integer.

Sample Explanation 2

The integers JOI writes down are:
- For $ (l, r) = (1, 3) $, it is $ 5 $
- For $ (l, r) = (1, 4) $, it is $ 2 $
- For $ (l, r) = (1, 5) $, it is $ 2 $
- For $ (l, r) = (2, 4) $, it is $ 5 $
- For $ (l, r) = (2, 5) $, it is $ 4 $
- For $ (l, r) = (3, 5) $, it is $ 4 $

The $ L (= 3) $-th smallest integer among these is $ 4 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 3 2 4 3 1 2
样例输出
3