-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva11991.java
More file actions
40 lines (36 loc) · 1016 Bytes
/
Copy pathUva11991.java
File metadata and controls
40 lines (36 loc) · 1016 Bytes
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
import java.util.* ;
import java.io.* ;
/**
*
* @author mostafa kamel
*/
public class Uva11991
{
static final int N = (int)(1e6 + 2);
public static void main(String[] args) throws IOException
{
Scanner sc = new Scanner(System.in);
PrintWriter pr = new PrintWriter(System.out);
while(sc.hasNext())
{
int n = sc.nextInt();
int m = sc.nextInt();
ArrayList<Integer> [] adjList = new ArrayList[N];
for (int i = 0; i < N ; i++)
adjList[i] = new ArrayList();
for (int i = 0; i < n ; i++)
adjList[sc.nextInt()].add(i+1);
for (int i = 0; i < m ; i++)
{
int k = sc.nextInt();
int v = sc.nextInt();
if(adjList[v].size() < k)
pr.println(0);
else
pr.println(adjList[v].get(k-1));
}
}
sc.close();
pr.close();
}
}