M - Sereja and Suffixes
来源:互联网 发布:大数据生态系统 编辑:程序博客网 时间:2024/06/06 12:31
回家后,发现自己的效率急剧下降,还好今天搞懂一hash水题
Crawling in process...Crawling failedTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
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
10 101 2 3 4 1 2 3 4 100000 9999912345678910
6666654321
成型代码:
我突然想到水题对自己来说,就是只有自己会做了之后才是水题,不然就不是水题
想想不论多困难,只要趟过一次,就不再是问题了,就像我哥结婚,我和姐夫一起去拉礼炮一样,生怕自己转的方式不对,怕误了最佳时辰。。。。想想都是泪啊。
- M - Sereja and Suffixes
- M - Sereja and Suffixes--dp
- B. Sereja and Suffixes
- C - Sereja and Suffixes
- Sereja and Suffixes
- codeforces368B - Sereja and Suffixes
- coderforce --B. Sereja and Suffixes
- CF#215DIV2:B. Sereja and Suffixes
- codeforce Sereja and Suffixes(简单题)
- CodeForces 368B Sereja and Suffixes
- CF#215 DIV2: B. Sereja and Suffixes
- CodeForces 368B-Sereja and Suffixes【模拟】
- Codeforces 368B Sereja and Suffixes
- CodeForces 368B:Sereja and Suffixes【水】
- Codeforces-368B-Sereja and Suffixes
- 【codeforces 368B Sereja and Suffixes】+ 预处理
- CodeForces 368B Sereja and Suffixes
- codeforces 368 B. Sereja and Suffixes
- 1.30张佳莉
- 1.30日志
- eclipse maven plugin 插件 安装 和 配置
- Linux系统中静态库和动态库的生成和使用
- 171Excel Sheet Column Number
- M - Sereja and Suffixes
- 在MSVC2012中使用freeglut代替glut
- 直接拿来用!最火的Android开源项目整理
- Matlab学习笔记(五)
- [Leetcode]N-Queens
- NYOJ 喷水装置(一) 6
- Android Studio Study
- java解析xml,详细解释
- HDOJ 1062 Rightmost Digit