4579: C
题目描述
One day, Mikasa found a password consisting of numbers from 1 ~ 9. She wants to know how conspicuous this password is to Allen. Allen has a visual threshold of k, and only the number whose length is not less than k can be noticed by him.
We define f(x, S) as the number of occurrences of the number x in the password S.
Then we define the conspicuousness g(S) of a password S:
g(S) = max (x∈S, |x|≥k) f(x, S)
Noticed: x ∈ S means number x is a subnumber of the password S. For example, 23 ∈ 1234 is true and 24 ∈ 1234 is not.
Since M ikasa does not know the visual threshold k, please help calculate the conspicuousness g(S) under the q
输入格式
The first line contains two positive integers n(1 ≤ n ≤ 3 ∗ 10e5) and q(1 ≤ q ≤ 3 ∗ 10e5), indicating the length of the password and the number of situations;
The second line contains a number with a length of n, which represents the password discovered by M ikasa; In the next q line, each line has a positive integer k(1 ≤ k ≤ n), which represents the visual threshold of Allen.
输出格式
输入样例 复制
3 2
131
1
2
输出样例 复制
2
1