問題一覧 > 通常問題

No.2334 Distinct Cards

レベル : / AI推定難易度 : 400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 244
作問者 : SSRS / テスター : 👑 Kazun 👑 Nachia
お気に入りにしたユーザー ProblemId : 4551 / 自分の提出
問題文最終更新日: 2023-06-02 20:44:51
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 391 (順位表) の他の問題:

Problem Statement

There are $N$ cards. The $i$-th card ($1 \leq i \leq N$) has the integer $A_i$ written on it.
When taking $K$ cards from among them, find the minimum possible number of distinct integers written on the taken cards.

Input

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

$N$ $K$
$A_1$ $A_2$ $\cdots$ $A_N$

Output

Print the answer to standard output on $1$ line. End the output with a newline.

Constraints

The input satisfies the following constraints.

  • $1 \leq N \leq 100\,000$
  • $1 \leq K \leq N$
  • $1 \leq A_i \leq N \ (1 \leq i \leq N)$
  • All input values are integers.

Sample

Sample 1
Input
5 3
1 2 2 1 3
Output
2

If you take cards $1,2,3$, the integers written on the taken cards are $1, 2$, which is $2$ distinct integers.
It is impossible to take $3$ cards so that the integers written on the taken cards are $1$ distinct integer or fewer, so print $2$.

Sample 2
Input
4 4
1 2 3 4
Output
4

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。