传送门:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18696
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
map<int ,vector<int> >mp;
void Deal_with() {
int n,m;
while(~scanf("%d %d",&n,&m)) {
mp.clear();
int tempa,tempb;
for(int i = 1 ; i <= n ; i++) {
scanf("%d",&tempa);
//printf("%d\n",tempa);
//if(!mp.count(tempa)) mp[tempa] = vector <int > ();
mp[tempa].push_back(i);
}
for(int i = 1 ; i <= m ; i++) {
scanf("%d %d",&tempa,&tempb);
//printf("%d %d\n",tempa,tempb);
if(!mp.count(tempb) || mp[tempb].size() < tempa ){
puts("0");
continue;
}
printf("%d\n",mp[tempb][tempa-1]);
}
}
}
int main(void) {
// freopen("a.in","r",stdin);
Deal_with();
return 0;
}