문제
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 papers (), and her -th paper has accumulated citations () from other papers in the research literature.
Bessie has heard that an academic's success can be measured by their -index. The -index is the largest number such that the researcher has at least papers each with at least citations. For example, a researcher with papers and respective citation counts has an -index of , whereas if the citation counts were then the -index would be .
To up her -index, Bessie is planning to write up to survey articles (), each citing many of her past papers. However, due to page limits, she can only cite at most papers in each survey (). 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 -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 index is ethically dubious; other academics are not recommended to follow Bessie's example here.
입력
The first line contains , , and .
The second line contains space-separated integers .
출력
The maximum -index on a single line.
예제 입력 1
4 4 1
1 100 1 1
예제 출력 1
3
예제 입력 2
4 1 4
1 100 1 1
예제 출력 2
2
점수
Test cases 1-6 satisfy .Test cases 7-16 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인