Author: A Rupeswar Subudhi
Tester: Pritish Priyatosh Nayak
Editorialist: A Rupeswar Subudhi
set, data structures
Collect tickets from every ticket-counter and show the ticket of lowest value greater than the requirement v at every checkpost or determine that no such ticket exists and you have to pay the fine.
Whenever Chef visits a ticket-counter, store the value v of the ticket in an ordered set and then when Chef visits a checkpost retrieve the value whose value is greater than or equal to the requirement v of the checkpost.
If no such value exists, print -1 indicating that Chef has to pay the fine.
See tester/setter code for details regarding how to implement.
Time Complexity : O(T * N* log(N))