#P9937. [USACO21OPEN] Acowdemia I B
[USACO21OPEN] Acowdemia I B
Problem Description
Because of her love for computer science, and the temptation of one day becoming “Dr. Bessie”, the cow Bessie has started pursuing a PhD in computer science. After some time doing research, she has published papers (), and her -th paper has received citations from other research papers ().
Bessie has heard that academic achievement can be measured using the -index. The -index is the largest integer such that the researcher has at least papers with at least citations each. For example, if a researcher has papers with citation counts , then the -index is . However, if the citation counts are , then the -index would be .
To increase her -index, Bessie plans to write a survey paper and cite some of her own papers in it. Because of page limits, she can cite at most papers in this survey (), and she can cite each of her papers at most once.
Please help Bessie find the maximum -index she can achieve after writing this survey.
Note that Bessie’s advisor may tell her that writing a survey purely to increase her -index might be considered academic misconduct; we do not recommend other researchers imitate Bessie’s behavior.
Input Format
The first line contains and .
The second line contains space-separated integers .
Output Format
Output the maximum -index Bessie can achieve after writing the survey.
4 0
1 100 2 3
2
4 1
1 100 2 3
3
Hint
Sample Explanation 1
Bessie cannot cite any of her previously written papers. As mentioned above, the -index of is .
Sample Explanation 2
If Bessie cites her third paper, the citation counts become . As mentioned above, the -index for these citation counts is .
Test Point Properties
- Test points satisfy .
- Test points satisfy .
- Test points satisfy .
Translated by ChatGPT 5