欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF368B.Sereja and Suffixes
Sereja and Suffixes
Sereja has an array a, consisting of n integers a1, a2, ..., a**n. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., l**m (1 ≤ l**i ≤ n). For each number l**i he wants to know how many distinct numbers are staying on the positions l**i, l**i + 1, ..., n. Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., a**n.?
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 each l**i.
Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., a**n (1 ≤ a**i ≤ 105) — the array elements.
Next m lines contain integers l1, l2, ..., l**m. The i-th line contains integer l**i (1 ≤ l**i ≤ n).
Output
Print m lines — on the i-th line print the answer to the number l**i.
Samples
10 10
1 2 3 4 1 2 3 4 100000 99999
1
2
3
4
5
6
7
8
9
10
6
6
6
6
6
5
4
3
2
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |