Codeforces Round #215 (Div. 2) B. Sereja and Suffixes

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    int n,m;
    cin >> n >>m;
    vector<int> a(n),l(m);
    for(int i = 0 ; i < n ; ++ i)
        cin >>a[i];
    for(int i = 0 ; i < m; ++ i)
        cin >>l[i];
    set<int> diff;
    vector<int> res(n,0);
    for(int i = n-1;i >=0; -- i){
        diff.insert(a[i]);
        res[i] = diff.size();
    }
    for(int i = 0; i< m; ++ i){
        cout<<res[l[i]-1]<<endl;
    }
    return 0;
}

 

posted @ 2013-11-28 22:46  OpenSoucre  阅读(236)  评论(0编辑  收藏  举报