#P3416. Concert Tickets

Concert Tickets

当前没有测试数据。

Description

There are n concert tickets available, each with a certain price. Then, m customers arrive, one after another.

Each customer announces the maximum price they are willing to pay for a ticket, and after this, they will get a ticket with the nearest possible price such that it does not exceed the maximum price.

Input Format

The first input line contains integers n and m: the number of tickets and the number of customers.

The next line contains n integers h1,h2,,hn: the price of each ticket.

The last line contains m integers t1,t2,,tm: the maximum price for each customer in the order they arrive.

Output Format

Print, for each customer, the price that they will pay for their ticket. After this, the ticket cannot be purchased again.

If a customer cannot get any ticket, print 1.

5 3
5 3 7 8 5
4 8 3
3
8
-1

Hint

<li> 1n,m2105 </li> <li> 1hi,ti109 </li>

Source

CSES