아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Building Bombing

시간 제한3초메모리 제한1024 MB

요약
건물 L이 왼쪽에서 K번째로 보이는 건물이 되도록 최소 개수의 건물을 폭파하는 문제이다.
난이도

보통10점 중 6점

유형
그리디, 배열, 동적 계획법
정답자
아직 제출이 없습니다

문제

KAIST has a series of NN buildings in a row, numbered from 11 to NN, from left to right. Building ii has a height of h_ih\_i. Building ii is visible from the left if and only if every building on its left has a height strictly less than h_ih\_i.

Your lab is located in building number LL. Since your favorite number is KK, you want to make your lab building the KK-th tallest building visible from the left. To achieve your goal, you will blow up some of the buildings.

For example, suppose there are N=7N=7 buildings in a row and their heights are \[10,30,90,40,60,60,80]\[10,30,90,40,60,60,80]. Your lab is located at building number L=2L=2 and your favorite number is K=3K=3. After blowing up buildings 33 and 77, the buildings visible from the left will be buildings 11, 22, 44, and 55. Then your lab becomes the 33rd tallest building visible from the left, as desired.

What is the minimum number of buildings to blow up to make your lab building the KK-th tallest building visible from the left?

입력

The first line contains three space-separated integers NN, LL, and KK.

The second line contains NN space-separated integers h_1,…,h_Nh\_1,\dots ,h\_N.

출력

Output the minimum number of buildings to blow up to make your lab building the KK-th tallest building visible from the left. If it is impossible to do so, output −1-1 instead.

제한

  • 1≤L≤N≤100,0001\le L\le N\le 100\\, 000
  • 1≤K≤101\le K\le 10
  • 1≤h_i≤1091\le h\_i\le 10^9 (1≤i≤N)(1\le i\le N)

예제2

  1. 예제 1

    입력
    7 2 3
    10 30 90 40 60 60 80
    
    예상 출력
    2
    
  2. 예제 2

    입력
    3 2 2
    30 20 10
    
    예상 출력
    -1