Long Enough Plateaus X77133


Statement
 

pdf   zip

html

Given a sequence of integers, a plateau is a subsequence of consecutive identical numbers. For example, in 1 2 2 2 1 4 we have a plateau of length 3 formed by 2’s, and the rest of the plateaus have length 1. Your task is to write a program that checks for long enough plateaus.

Input

First comes an integer n≥ 1; then, starting in the next line, a sequence of integers follows, possibly spanning several lines in an unpredictable manner.

Output

If there are n or more consecutive occurrences of the same number, say i, the answer should be "A plateau of i’s of length at least n occurs.", with the right values of i and n inserted appropriately: i must be such that the plateau of n occurrences of i is the first plateau of that length. Otherwise, the answer should be "No plateau of length n occurs." Don’t forget the period at the end of these sentences.

Public test cases
  • Input

    3
    1 2 2 2 1 4
    
    

    Output

    A plateau of 2's of length at least 3 occurs.
    
  • Input

    5
    1 2 2
    2 2 2 3
    
    

    Output

    A plateau of 2's of length at least 5 occurs.
    
  • Input

    1
    7 2 2
    
    

    Output

    A plateau of 7's of length at least 1 occurs.
    
  • Input

    1
    7
    
    

    Output

    A plateau of 7's of length at least 1 occurs.
    
  • Input

    3
    1 1
    2 2 3
    3 4 4
    
    

    Output

    No plateau of length 3 occurs.
    
  • Information
    Author
    José Luis Balcázar
    Language
    English
    Official solutions
    Python
    User solutions
    Python