(寒假CF)!

题意:给出两组数字,第二组数字代表第一组数字中的第几位。求从那一位开始,后面不同的数的个数

Description

Sereja has an array a, consisting of n integers a1a2, ..., an. 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, ..., lm(1 ≤ li ≤ n). For each number li he wants to know how many distinct numbers are staying on the positions lili + 1, ..., n. Formally, he want to find the number of distinct numbers among ali, 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 each li.

Input

The first line contains two integers n and m(1 ≤ n, m ≤ 105). The second line contains n integers a1a2, ..., an(1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-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
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,k,i,l;
    int a[100001],b[100001],s[100001];
    while(~scanf("%d %d",&n,&m))
    {
        memset(b,0,sizeof(b));
        memset(s,0,sizeof(s));
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        int ans=0;
        for(i=n;i>=1;i++)
        {
            if(!s[a[i]])
            {
                ans++;
                s[a[i]]=1;
            }
                b[i]=ans;
        }
        while(m--)
        {
            scanf("%d",&l);
            printf("%d\n",b[l]);
        }
    }
    return 0;
}
时间: 2024-08-10 00:06:48

(寒假CF)!的相关文章

(寒假CF)乐

题意:ekjfkj=output 依此解开密码,得到题意求第n位(本身是素数,同时反过来也是素数的数) 题解:打表 注意:数组开大,反过来的数不能是自己本身 Descriptionqd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf. Inputjxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 ≤ d ≤

(寒假CF)快

题意:给出一组数字,得到区间[1,a1],[a1+1,a1+a2],[a1+a2+1,a1+a2+a3]..... 再给出一组数字,求这些数字属于第几个区间 注意:记得数组开大,容易超时 DescriptionIt is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch. Marmot brought Mole n ordered piles of worms such that i-th pi

(寒假CF) 比赛要

题意:给位数和位数和 求符合要求的最大值和最小值 //想法都有了,可是却没有做粗来(你484傻啊?? ?(?_?)? ??) Description You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The requir

(寒假CF)惨淡一点

题解:类似于最大上升子序列 Iahub got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and fli

寒假二三事

寒假快要结束了,写下流水账第一件事情是注意身体注意身体注意身体第二件事情是还有大概意识到自己就是个普通人,很笨,也不是很努力,能够做到的事情很有限希望接下来的时间好好加油,每天都要开心>_<希望以后每当难过的时候,来看一下自己写的这些心情,就继续加油 学习方面:就抱着去学一样新的东西,去get一种新的姿势去学就好拉,比赛打得不好也不要总是难过,好好地去补题,去思考就好.静下心来踏踏实实的努力学一些找工作有关的东西,还是很迷茫的说啊,什么都不会,看到那些招聘的要求,只会一点C和一点点STL都不能

寒假总结。。。

虽然刷了4章usaco,但跟没有刷一样,唯一有印象的就是判大素数模版,反着做背包的dp,反着做数位dp(逆向思维),对lis统计的判重,还有连通分量有了一点大概的印象,还有更加坚信了构造就是找规律,然后提高了一下代码能力,没了. 这个寒假最失败的一点就是把白天和夜晚倒过来过,白天睡觉,晚上刷题,这样好累,做题的效率好低..今天一定要把时间调整过来. 还有三天,我的寒假还没有结束!三天搞6个专题(其实是5个半,splay再写几道经典题就结束了,然后LCT应该很好学,和splay有联系),我的寒假才

2016-2017寒假社会实践报告

今年的寒假和去年一样,只做了一件事就是ACM,开始的几天并不顺利,刚放假的几天去青岛玩了几天,电脑电源落在那了,几天后才快递过来.寒假的任务看似很少,只是刷完ACMsteps,但是实际做起来很慢. 调整状态篇 最初的几天,可算是十分的艰难,放假前刷到了7.3也就是数学的那章,感觉自己进入了一个新的世界,欧拉定理,矩阵快速幂,计算几何,凸包……想想都头大,每天基本上是上午看知识点,下午,如果觉得可以搞就开始想题,效率十分的低,特别是卡精度的题,double在运算过程中会损失精度,所以中间过程中能不

寒假训练计划

寒假训练计划 计划 1.校内天梯赛+补题 2.cf 250~550 泛做 3.专题补全:遇到不会的知识点马上去学习 并泛做该知识点3~5题 4.一天至少三题(扣除水题) 做题记录 mark 题号 通过人数 做题时间 题解&吐槽 y timus 1128 1185 2018/02/06 TBD 原文地址:https://www.cnblogs.com/wuyuanyuan/p/8423190.html

2018寒假 acm训练计划

任务总览: 1.<aha>1,3,4章 2.紫书 7,9,10章(不知道有没有时间学8章) 3.队里训练赛跟做 4.全国多校算法学习 5.cf2天一套 6.c++ 想做的有点多,先试试看自己能不能做得来这些,再调整 时间安排 : 2.7-2.11 <aha> 1,3,4,章 全国多校学习  dp,直播两场 一二场比赛重做 2天一套cf 晚上 学习c++ 2.12-2.17 紫书 7章 全国多校 学习 直播 课件跟进 三四场重现 重做 2天一套cf 2.18-2.23 紫书 9章 全