#P16744. [GKS 2019 #H] H-index

[GKS 2019 #H] H-index

Problem Description

It is important for researchers to write many high quality academic papers. Jorge has recently discovered a way to measure how impactful a researcher's papers are: the H-index.

The HH-index score of a researcher is the largest integer hh such that the researcher has hh papers with at least hh citations each.

Jorge has written NN papers in his lifetime. The i-th paper has AiA_i citations. The number of citations that each paper has will never change after it is written. Please help Jorge determine his H-index score after each paper he wrote.

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case begins with a line containing NN, the number of papers Jorge wrote.

The second line contains NN integers. The i-th integer is AiA_i, the number of citations the i-th paper has.

Output Format

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is a space-separated list of integers. The i-th integer is the H-index score after Jorge wrote his i-th paper.

2
3
5 1 2
6
1 3 3 2 2 15
Case #1: 1 1 2
Case #2: 1 1 2 2 2 3

Hint

In Sample Case #1, Jorge wrote N=3N = 3 papers.

  • After the 1st paper, Jorge's H-index score is 11, since he has 11 paper with at least 11 citation.
  • After the 2nd paper, Jorge's H-index score is still 11.
  • After the 3rd paper, Jorge's H-index score is 22, since he has 22 papers with at least 22 citations (the 1st and 3rd papers).

In Sample Case #2, Jorge wrote N=6N = 6 papers.

  • After the 1st paper, Jorge's H-index score is 11, since he has 11 paper with at least 11 citation.
  • After the 2nd paper, Jorge's H-index score is still 11.
  • After the 3rd paper, Jorge's H-index score is 22, since he has 22 papers with at least 22 citations (the 2nd and 3rd papers).
  • After the 4th paper, Jorge's H-index score is still 22.
  • After the 5th paper, Jorge's H-index score is still 22.
  • After the 6th paper, Jorge's H-index score is 33, since he has 33 papers with at least 33 citations (the 2nd, 3rd and 6th papers).

Limits

1T1001 \le T \le 100.

1Ai1051 \le A_i \le 10^5.

Test set 1 (Visible)

1N10001 \le N \le 1000.

Test set 2 (Hidden)

1N1051 \le N \le 10^5.