#P463. 练83.5 二分查找2
练83.5 二分查找2
Description
Binary search on a sorted array is an excellent algorithm: the goal is to find if there exists a[k]=key in the sorted array a[]. If found, return ; otherwise, return .
- If there are multiple
a[k]=key, please output the largest . - The index starts counting from .
Input Format
The first line contains an integer , representing the length of the array.
The second line contains integers () within the int range, guaranteed to be in ascending order, separated by spaces.
The third line contains an integer , representing the number of queries.
The fourth line contains integers () within the int range, representing the values to search for in each query, separated by spaces.
Output Format
A single line containing the results for each query ( or ), separated by spaces.
Sample
4
-2 -2 -2 1
3
-2 -2 -13 3 -1