#P9460. 「EZEC-14」众数 I

    ID: 8350 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>贪心洛谷原创O2优化前缀和洛谷月赛

「EZEC-14」众数 I

Description

Given a sequence aa of length nn, we construct a sequence bb in the following way:

  • Initially, b=ab=a.
  • Then perform kk operations on bb in order. In each operation, choose any one element and modify it to any integer.

dXqwq defines the mode of a sequence as all numbers with the highest frequency. For example, the mode of [1,1,4,5,1,4][1,1,4,5,1,4] is 11, while the mode of [1,14,5,14,19,19,8,10][1,14,5,14,19,19,8,10] is 14,1914,19.

You need to find how many integers can possibly become the mode of bb.

Input Format

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

The second line contains nn integers aia_i.

Output Format

Output one integer, representing the number of values that can possibly become the mode.

In particular, if the answer is positive infinity, output pigstd.

5 0
1 2 3 4 5
5
5 1
1 2 3 4 5
pigstd
5 1
1 1 2 2 3
3

Hint

[Sample Explanation]

For the first group of testdata, in the end 1,2,3,4,51,2,3,4,5 can be the mode of the interval.

For the second group of testdata, after changing the first number to 6,7,8,9,6,7,8,9,\cdots, all of them will become the mode of the interval, so the answer is positive infinity.

For the third group of testdata, 1,2,31,2,3 can become the mode of the interval.

[Hint]

Allocating 10610^6 std::deque may not necessarily cause MLE when the memory limit is 1024MB.

[Constraints]

This problem uses bundled testcases.

  • Subtask 1 (20 pts): n5n\leq 5.
  • Subtask 2 (20 pts): n103n\leq 10^3.
  • Subtask 3 (20 pts): k=0k=0.
  • Subtask 4 (20 pts): k=1k=1.
  • Subtask 5 (20 pts): no special constraints.

For all data, 1n1061\leq n\leq 10^6, 0kn0\leq k\leq n, 1ain1\leq a_i\leq n.

Translated by ChatGPT 5