Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Easy Problem from Rujia Liu?
  2.  
  3. Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an
  4. 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu's Presents 1 and 2), he
  5. occasionally sets easy problem (for example, 'the Coco-Cola Store' in UVa OJ), to encourage more
  6. people to solve his problems :D
  7.  
  8. Given an array, your task is to find the k-th occurrence (from left to right) of an
  9. integer v. To make the problem more difficult (and interesting!), you'll have to answer
  10. m such queries.
  11.  
  12. Input
  13. There are several test cases. The first line of each test case contains two integers n,
  14. m(1<=n,m<=100,000), the number of elements in the array, and the number of queries.
  15. The next line contains n positive integers not larger than 1,000,000. Each of the
  16. following m lines contains two integer k and v (1<=k<=n, 1<=v<=1,000,000). The input is
  17. terminated by end-of-file (EOF). The size of input file does not exceed 5MB.
  18.  
  19. Output
  20. For each query, print the 1-based location of the occurrence. If there is no such
  21. element, output 0 instead.
  22.  
  23. Sample Input
  24. 8 4
  25. 1 3 2 2 4 3 2 1
  26. 1 3
  27. 2 4
  28. 3 2
  29. 4 2
  30.  
  31. Sample Output
  32. 2
  33. 0
  34. 7
  35. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement