Finding Keys
시간 제한2초메모리 제한2048 MB
원형 열쇠고리에서 각 열쇠마다 다음 k개 열쇠와의 대소 비교 패턴이 유일해지는 최소 k를 구한다.
문제
Wolfgang Amadeus Mozart has too many keys! He has keys of distinct lengths on his circular keychain. Unfortunately, Wolfgang can only judge whether a key fits into a door by its relative size compared to the keys surrounding it. Let the -pattern of a key be the sequence of relative key lengths of the keys following key in clockwise order on the keychain. For example, if keychain has keys of lengths in clockwise order, then the -pattern of the key of length can be expressed as the string “<>>”, since < , > , and > . Note that the last key of length is followed by the first key of length .
Please help Wolfgang determine for each key the smallest such that the -pattern of the key is unique (no other key’s -pattern is the same).
입력
The first line of input contains a single integer (), the number of keys on Wolfgang’s circular keychain.
The next lines each contain an integer between and representing the length of one key. The key lengths are given in their clockwise order on the keychain. It is guaranteed that all key lengths are unique.
출력
Output lines, one integer per line. The th integer should be the smallest such that the -pattern of key (in input order) is unique among all -patterns. If there exists no such , then the th integer should be .