Long Enough Plateaus X77133


Statement
 

pdf   zip

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 n1n\geq 1; then, starting in the next line, a sequence of integers follows, possibly spanning several lines in an unpredictable manner.

Output

If there are nn or more consecutive occurrences of the same number, say ii, the answer should be "A plateau of ii’s of length at least nn occurs.", with the right values of ii and nn inserted appropriately: ii must be such that the plateau of nn occurrences of ii is the first plateau of that length. Otherwise, the answer should be "No plateau of length nn 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