JAPC1002 Editorial

PROBLEM LINK:

Practice

Contest

Author: A Rupeswar Subudhi

Tester: Pritish Priyatosh Nayak

Editorialist: A Rupeswar Subudhi

DIFFICULTY:

Simple

PREREQUISITES:

set, data structures

PROBLEM:

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.

EXPLANATION:

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))

SOLUTIONS:

Setter Solution
C++ Solution