Maximum consecutive subsequence P94336


Statement
 

pdf   zip

thehtml

Given a sequence of n integer numbers x1xn, and an integer number x, let L(x) be the maximum length of all the subsequences made up of only x. That is, L(x) is the maximum number of times that x appears consecutively in the sequence (or zero, if x is not there). Given several x, can you compute each L(x)?

Input

Input consists of several cases. Every case begins with n, followed by x1xn, followed by a natural number q, followed by q different integer numbers x about which you are asked.

Output

For every case, print a line with the q answers L(x) separated with spaces.

Public test cases
  • Input

    9   -10 30 30 -10 -10 -10 25 25 30
    3   -10 20 30
    
    10  1 1 -4 -4 -4 6 8 8 8 8
    5   8 6 5 1 -4
    
    15  7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
    2   7 8
    

    Output

    3 0 2
    4 1 0 2 3
    15 0
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++