#BS0000172. Chỉ số H (H-Index)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chỉ số H (H-Index)
H-Index
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A researcher has published papers. Paper has been cited times, where is a non-negative integer. The H-index is the greatest integer for which at least papers have each received at least citations. Determine this value; the H-index may be .
Input
The first line contains the integer , the number of papers. The second line contains integers , the citation counts for the papers in order.
Output
Print exactly one integer: the maximum H-index.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
5
3 0 6 1 5
Output
3
Explanation
The five citation counts are . For , three papers have at least three citations: , , and . For , only the papers with and citations qualify, so there are fewer than four. Thus the largest feasible value is .
Input
3
0 0 0
Output
0
Explanation
All papers have zero citations. No satisfies the definition, so the H-index is .