CitadelOA #13
Find Consistent Logs
估计中等可在线判题
Among the users appearing in the whole array, let f be the minimum number of occurrences. Find the maximum length of a contiguous subarray in which the highest user occurrence count is exactly f; it does not require every user in the subarray to have the same frequency.
输入格式
The first line contains n, followed by the user IDs; complete original bounds 1≤n≤300000, 1≤ID≤1000000000.
输出格式
Output a single integer, the answer.
样例 1
输入:
10
1 2 1 3 4 2 4 3 3 4
输出:
8
样例 2
输入:
3
1 1 1
输出:
3
样例 3
输入:
4
1 2 1 3
输出:
3
样例说明
The outputs of the three public examples are, in order: 8; 3; 3. These answers were verified by independent enumeration or direct simulation.