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

OpenSoucre發表於2013-11-28
#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;
}

 

相關文章