Exact match
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given an array of integers sorted in non-decreasing order, your task is to write a program that handles queries of the following type:
- For a given number ( x_i ), determine the position of its rightmost occurrence in the array.
Input
The first line of the input contains two natural numbers ( n ) and ( m ) (( 1 n, m 100,000 )). The second line contains ( n ) integers representing the array ( A ). The next ( m ) lines each contain a query number ( x_i ). Both the elements of the array and the query numbers can have absolute values up to ( 10^9 ).
Output
For each query, output the position of the rightmost occurrence of the number in the array. If the number is not present, output zero.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 536
Acceptance rate 44%