这题用map容器做存然后用用vector存第k个元素的位置再加一些特别判断有没有就OK了
#include<cstdio>
#include<map>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int mx = 1e6+5;
map<int,vector<int>>mp;
int main(){
int n,m;
while(cin>>n>>m){
mp.clear();
int k,v;
for(int i = 1; i <= n; i++){
cin>>v;
mp[v].push_back(i);
}
for(int i = 1; i <= m; i++){
cin>>k>>v;
if(!mp.count(v) || k>mp[v].size()) puts("0");
else printf("%d\n",mp[v][k-1]);
}
}
return 0;
}