#d2925. 频率相同的最长子序列
频率相同的最长子序列
Longest Subsequence with Equal Frequencies
Problem Description
You are given an array of length . Choose a subsequence of such that every element that appears in the subsequence appears the same number of times. Find the length of the longest such subsequence.
Input Format
The input consists of two lines. The first line contains an integer , the size of the array.
The next line contains space-separated integers .
Output Format
Output a single integer, the answer.
Sample Input 1
6
1 3 2 1 4 2
Sample Output 1
4
Sample Explanation
The subsequence $\underline{1},\ 3,\ \underline{2},\ \underline{1},\ 4,\ \underline{2}$ (taking the underlined elements, i.e. ) satisfies the condition, and it is the longest possible.
Sample Input 2
4
100 100 4 100
Sample Output 2
3
Sample Input 3
8
1 2 3 3 3 2 6 6
Sample Output 3
6