#C6430. Maximum Books in Series
Maximum Books in Series
Maximum Books in Series
George loves to read, but he believes that a series of books is only interesting if all the books have the same number of pages. Given a list of books with their page counts, your task is to determine the maximum number of books that George can read as a series where each book has the same number of pages. In other words, for each test case, find the maximum frequency of any page count that appears at least twice. If no such series exists, the answer is 0.
The formula for the maximum series count for a given test case can be expressed as:
[ \max_{p \in P} { f(p) } \quad \text{if } \max_{p \in P} { f(p) } \geq 2,\quad \text{else } 0 ]
where \(P\) is the set of page numbers and \(f(p)\) is the frequency of page number \(p\).
inputFormat
The input is read from standard input and has the following format:
T N1 pages1[0] pages1[1] ... pages1[N1-1] N2 pages2[0] pages2[1] ... pages2[N2-1] ... NT pagesT[0] pagesT[1] ... pagesT[NT-1]
Here, T is the number of test cases. For each test case, the first line contains an integer N indicating the number of books, followed by a line with N integers representing the page count of each book.
outputFormat
For each test case, output a single line to standard output containing one integer: the maximum number of books in a series (i.e., the maximum frequency of a page count that appears at least twice). If no page appears more than once, output 0.
## sample2
3
100 200 300
4
50 50 50 50
0
4
</p>