#C2126. Efficient Parking Lot Management

    ID: 45408 Type: Default 1000ms 256MiB

Efficient Parking Lot Management

Efficient Parking Lot Management

You are assigned to manage a parking lot with a limited number of slots. Cars arrive and depart at specific times. Your task is to process the events in chronological order, and for each departure (exit) event, calculate the parking fee based on the duration the car was parked.

When a car enters, if there is an available slot, record its entry time. If the parking lot is full, ignore that entry event. When a car leaves, compute its parking fee using the following formula:

\( \text{Fee} = 10 \times \lceil \frac{T}{60} \rceil \)

where \(T\) is the total parked time in minutes, and any partial hour is rounded up to the next full hour.

Assume that:

  • The parking lot starts out empty.
  • Events are provided in chronological order.
  • Time is given in the format hh:mm (with hours from 00 to 23 and minutes from 00 to 59).
  • If a car cannot enter due to a full parking lot, ignore its entry.
  • </p>

    inputFormat

    The input is read from standard input and has the following format:

    The first line contains two integers, \(N\) and \(M\), where \(N\) is the total number of parking slots and \(M\) is the total number of events.

    The next \(M\) lines each contain an event in one of the following formats:

    • entry car_id hh:mm — a car with unique identifier car_id enters the parking lot at time hh:mm.
    • exit car_id hh:mm — the car with unique identifier car_id exits the parking lot at time hh:mm.

    outputFormat

    For each exit event, output a line to standard output containing the car identifier and the parking fee separated by a space.

    If there are no exit events, no output is produced.

    ## sample
    3 5
    entry 1234 10:00
    entry 5678 10:30
    entry 9101 11:00
    exit 1234 13:45
    exit 5678 14:15
    
    1234 40
    

    5678 40

    </p>