#C10361. Calculate the H-Index
Calculate the H-Index
Calculate the H-Index
The H-Index is a metric that attempts to measure both the productivity and citation impact of the publications of a researcher. Given a list of citation counts for each paper, the H-Index is defined as the maximum value h such that the researcher has published h papers that have each been cited at least h times.
Mathematically, this can be expressed as:
$$h = \max\{h : \text{number of papers with at least } h \text{ citations} \geq h\}$$
The input consists of several test cases. Each test case begins with an integer indicating the number of papers, followed by a line of space-separated integers representing the citation counts of the papers. The input terminates with a test case where the number of papers is 0. For each test case, output the computed H-Index on a separate line.
inputFormat
Input Format:
- Multiple test cases are provided via standard input.
- For each test case:
- The first line contains an integer n (n ≥ 0), which indicates the number of papers. A value of 0 indicates the end of input.
- The second line contains n space-separated integers representing the citation counts.
- There is no extra data after the terminating test case.
outputFormat
Output Format:
- For each test case (except the terminating case), output a single integer representing the calculated H-Index on a new line.
5
6 5 3 1 0
4
4 4 4 4
8
10 8 5 4 3 3 2 1
0
3
4
4
</p>