#P7557. [USACO21OPEN] Acowdemia S

[USACO21OPEN] Acowdemia S

Description

Because of her love for computer science, and the temptation of someday becoming “Dr. Bessie,” the cow Bessie has started pursuing a PhD in computer science. After some time doing research, she has published NN papers (1N1051 \leq N \leq 10^5), and her ii-th paper has received cic_i citations from other research works (0ci1050 \leq c_i \leq 10^5).

Bessie has heard that academic achievement can be measured using the hh-index. The hh-index is the largest integer hh such that the researcher has at least hh papers with at least hh citations each. For example, if a researcher has 44 papers with citation counts (1,100,2,3)(1,100,2,3), then the hh-index is 22. However, if the citation counts are (1,100,3,3)(1,100,3,3), then the hh-index would be 33.

To increase her hh-index, Bessie plans to write at most KK survey papers (0K1050 \leq K \leq 10^5), and in each survey she will cite many of her previous papers. However, due to page limits, she can cite at most LL papers in a single survey (0L1050 \leq L \leq 10^5). Of course, within one survey she can cite any given paper at most once (but a paper can be cited in multiple surveys).

Please help Bessie find the maximum hh-index she can achieve after writing these surveys. Bessie cannot cite her other surveys within a survey.

Note that Bessie’s advisor may warn her that writing surveys purely to increase the hh-index may be considered academically unethical; we do not recommend other researchers imitate Bessie’s behavior.

Input Format

The first line contains NN, KK, and LL.

The second line contains NN space-separated integers c1,,cNc_1,\ldots, c_N.

Output Format

Output the maximum hh-index that can be achieved.

4 4 1
1 100 1 1
3
4 1 4
1 100 1 1
2

Hint

Sample Explanation

For the first sample, Bessie can write at most four surveys, and each survey can cite at most one paper. If Bessie cites her first and third papers two times each, her hh-index becomes 33.

For the second sample, Bessie can write at most one survey. If Bessie cites any one of her first, third, or fourth papers, her hh-index becomes 22.

Test Point Properties:

  • Test points 161 \sim 6 satisfy N100N \le 100.
  • Test points 7167 \sim 16 have no additional constraints.

Notes

Problem by: Dhruv Rohatgi

Translated by ChatGPT 5