Problem list
Log in
#r03101 · Online Judge > GoldOJ

Sorted Search Queries

Silver IV 2.0 s 256 MB

A set of $n$ distinct integers in ascending order is given, then $Q$ queries. For each query print the 1-based position of the value, or -1 if it is not present.

Input

Line 1: $n$ $Q$. Line 2: $n$ sorted distinct integers. Next $Q$ lines: a value each.

Output

Print the position (or -1) for each query, one per line.

Example 1

Input
8 3
1 2 3 5 7 9 11 15
11
3
4
Output
7
3
-1
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code