Maximum consecutive subsequence P94336


Statement
 

pdf   zip

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

Input

Input consists of several cases. Every case begins with nn, followed by x1xnx_1 \dots x_n, followed by a natural number qq, followed by qq different integer numbers xx about which you are asked.

Output

For every case, print a line with the qq answers L(x)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++