M - Sereja and Suffixes

来源:互联网 发布:大数据生态系统 编辑:程序博客网 时间:2024/06/06 12:31

    回家后,发现自己的效率急剧下降,还好今天搞懂一hash水题

M - Sereja and Suffixes

Crawling in process...Crawling failedTime Limit:1000MS    Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

SubmitStatus

 

Description

Sereja has an array a, consisting of n integers a1,a2, ..., an. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote outm integers l1, l2, ..., lm(1 ≤ li ≤ n). For each number li he wants to know how many distinct numbers are staying on the positionsli,li + 1, ...,n. Formally, he want to find the number of distinct numbers amongali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time. Help him, find the answer for the described question for eachli.

Input

The first line contains two integers n andm(1 ≤ n, m ≤ 105). The second line containsn integers a1,a2, ..., an(1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. Thei-th line contains integer li(1 ≤ li ≤ n).

Output

Print m lines — on the i-th line print the answer to the number li.

Sample Input

Input
10 101 2 3 4 1 2 3 4 100000 9999912345678910
Output
6666654321

 

成型代码:

  我突然想到水题对自己来说,就是只有自己会做了之后才是水题,不然就不是水题

  想想不论多困难,只要趟过一次,就不再是问题了,就像我哥结婚,我和姐夫一起去拉礼炮一样,生怕自己转的方式不对,怕误了最佳时辰。。。。想想都是泪啊。

 

 

 

 

 

0 0
原创粉丝点击