H-Index
InterviewTime limit1sMemory limit256 MB
Given N citation counts, compute the largest H with at least H papers cited at least H times.
- Level
Easy3 of 10
- Topics
- Sorting
- Solved
- No attempts yet
Problem
How do you measure a scientist's success? You can count the papers they published, or you can count the impact of those papers, that is, how often other scientists cite them. Both numbers matter. A paper has citation score if other scientists cited it times in their own papers. The h-index is one metric that reflects the number of papers and their citation scores at the same time.
The h-index is the largest integer with the following property: the scientist can choose papers whose citation score is at least . For example, if a scientist wrote 10 papers and each of them was cited 10 or more times, that scientist's h-index is at least 10.
Given the citation scores of every paper a scientist wrote, write a program that computes the h-index.
Input
The first line contains the number of papers ().
The second line contains citation scores separated by spaces. Each citation score is an integer between and .
Output
Print the h-index on the first line.
Hint
In the first example two papers have a citation score of 2 or more, the one cited 4 times and the one cited 8 times. Only one paper has a citation score of 3 or more, so the h-index is 2.