Concert Tickets Cses Problem set solution- Porblem statement- Time limit: 1.00 s Memory limit: 512 MB There are n n concert tickets available, each with a certain price. Then, m m customers arrive, one after another. Each customer announces the maximum price he or she is 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 The first input line contains integers n n and m m : the number of tickets and the number of customers. The next line contains n n integers h 1 , h 2 , … , h n h 1 , h 2 , … , h n : the price of each ticket. The last line contains m m integers t 1 , t 2 , … , t m t 1 , t 2 , … , t m : the maximum price for each customer. Output 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 − 1 . Constraints 1 ≤ n , m ≤ 2 ⋅ 10 5 1 ≤ n , m ≤ 2 ⋅
Comments
Post a Comment