-
Notifications
You must be signed in to change notification settings - Fork 0
/
11991.cpp
48 lines (47 loc) · 851 Bytes
/
11991.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<sstream>
#define lli long long int
#define ulli unsigned long long int
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define rep(i, n) for(int i=0;i<n;i++)
#define iterate(x) for(auto itr=x.begin(); itr!=x.end();itr++)
using namespace std;
int main()
{
map<int, vi> v;
int n, m;
while (cin >> n >> m)
{
v.clear();
rep(i, n)
{
int tmp;
cin >> tmp;
if (v.find(tmp) == v.end())
v.insert(make_pair(tmp, vi()));
v[tmp].push_back(i + 1);
}
rep(i, m)
{
int k, vv;
cin >> k >> vv;
if (v.find(vv) == v.end() || v[vv].size() < k)
cout << "0\n";
else
cout << v[vv][k - 1] << endl;
}
}
return 0;
}
//AC