Advertisement
Guest User

Untitled

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