1. 程式人生 > >6231 K-th Number (2017CCPC哈爾濱站 二分+尺取法)

6231 K-th Number (2017CCPC哈爾濱站 二分+尺取法)

Alice are given an array A[1..N] with N numbers.

Now Alice want to build an array B by a parameter K as following rules:

Initially, the array B is empty. Consider each interval in array A. If the length of this interval is less than K, then ignore this interval. Otherwise, find the K-th largest number in this interval and add this number into array B
.

In fact Alice doesn't care each element in the array B. She only wants to know the M-th largest element in the array B. Please help her to find this number.