8123: USACO 2021 US Open, Silver Problem 3. Acowdemia
[Creator : ]
Description
Bessie the cow has enrolled in a computer science PhD program, driven by her love of computer science and also the allure of one day becoming "Dr. Bessie". Having worked for some time on her academic research, she has now published N papers $(1≤N≤10^5)$, and her i-th paper has accumulated $c_i$ citations $(0≤c_i≤10^5)$ from other papers in the research literature.
Bessie has heard that an academic's success can be measured by their h-index. The h-index is the largest number h such that the researcher has at least h papers each with at least h citations. For example, a researcher with 4 papers and respective citation counts (1,100,2,3) has an h-index of 2, whereas if the citation counts were (1,100,3,3) then the h-index would be 3.
To up her h-index, Bessie is planning to write up to K survey articles $(0≤K≤10^5)$, each citing many of her past papers. However, due to page limits, she can only cite at most L papers in each survey $(0≤L≤10^5)$. Of course, no paper may be cited multiple times in a single survey (but a paper may be cited in several surveys).
Help Bessie determine the maximum h-index she may achieve after writing these survey articles. Bessie is not allowed to cite a survey from one of her surveys.
Note that Bessie's research advisor should probably inform her at some point that writing a survey solely to increase one's hℎ index is ethically dubious; other academics are not recommended to follow Bessie's example here.
To up her h-index, Bessie is planning to write up to K survey articles $(0≤K≤10^5)$, each citing many of her past papers. However, due to page limits, she can only cite at most L papers in each survey $(0≤L≤10^5)$. Of course, no paper may be cited multiple times in a single survey (but a paper may be cited in several surveys).
Help Bessie determine the maximum h-index she may achieve after writing these survey articles. Bessie is not allowed to cite a survey from one of her surveys.
Note that Bessie's research advisor should probably inform her at some point that writing a survey solely to increase one's hℎ index is ethically dubious; other academics are not recommended to follow Bessie's example here.
Input
The first line contains N, K, and L.
The second line contains N space-separated integers $c_1,…,c_N$.
Output
The maximum h-index on a single line.
Sample 1 Input
4 4 1
1 100 1 1
Sample 1 Output
3
In this example, Bessie may write up to 4 survey articles, each citing at most 1 paper. If she cites each of her first and third articles twice, then her h-index becomes 3.
Sample 2 Input
4 1 4
1 100 1 1
Sample 2 Output
2
In this second example, Bessie may write at most a single article. If Bessie cites any of her first, third, or fourth papers at least once, her h-index becomes 2.