#P9044. [PA 2021] Koszulki

[PA 2021] Koszulki

Problem Description

nn people take part in a contest, where the score of person ii is aia_i.

The organizers decide to give out at least kk gifts.

However, if 1x,yn,axay\exist 1 \leq x, y \leq n, a_x \geq a_y and xx does not receive a gift but yy receives a gift, then xx will be unhappy.

The organizers want everyone to be satisfied. Find the minimum number of gifts that must be given out.

Input Format

The first line contains two integers n,kn, k.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n.

Output Format

One line containing one integer, which is the required value.

5 3
75 90 120 75 40
4

Hint

Explanation for Sample #1

The best plan is to give gifts to everyone except the last person.

Constraints

For 100%100\% of the testdata, 1kn2×1031 \leq k \leq n \leq 2 \times 10^3, 1ai1201 \leq a_i \leq 120.

Translated by ChatGPT 5