The Only Mode
시간 제한2초메모리 제한1024 MB
0부터 3까지 각 값에 대해, 그 값이 다른 모든 값보다 더 많이 등장하는 가장 긴 부분 배열의 길이를 구한다.
문제
You are given an array of integers of size (indexed from to ) where is either , , , or .
A subarray of is defined as , and its size is .
A value is the only mode of a subarray if and only if appears strictly more often than other values in subarray .
Your task in this problem is to find, for each , the size of the longest subarray of such that is the only mode of that subarray, or determine if cannot be the only mode in any subarray.
입력
Input begins with an integer () representing the size of array . The next line contains integers ().
출력
Output four space-separated integers in a single line. Each integer represents the answer where is , , , and , respectively. For each value of , if there exists a subarray such that is the only mode in that subarray, then output the size of the longest subarray; otherwise, output .