题意:给出一个数在序列中第k次出现的位置。
思路:用map
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <ctype.h>
using namespace std;
const int maxn = 1e6 + 10;
int main()
{
int n,m,inte;
map<int, vector<int>> a;
while(cin >> n >> m)
{
a.clear();
for(int i=0; i<n; i++)
{
scanf("%d",&inte);
a[inte].push_back(i+1);
}
while(m--)
{
int k,v;
scanf("%d%d",&k,&v);
if(k > a[v].size() || !a.count(v))
printf("0\n");
else
printf("%d\n",a[v][k-1]);
}
}
return 0;
}