BNKQ
Time limit2sMemory limit512 MB
From a day of bank teller queue records, find each teller's processed-customer count and busiest one-hour window, then report the top three tellers.
- Level
Medium5 of 10
- Topics
- Hash map, Sorting, Implementation, Prefix sum
- Solved
- No attempts yet
Problem
Nili bank provides banking services to customers throughout the country. Each of its branches has several tellers who handle deposits and withdrawals for customers. Each teller has a queue of customers waiting to deposit or withdraw money through that teller. The bank records the customer, the time the customer stood in the queue (or was processed), and the teller.
With these records, the bank wants to know which tellers were busiest and what their peak time frame during the day was.
Write a program that reads the records for a single day and prints the three busiest tellers and their peak time frames.
Input
The first N lines (N < 10000) contain the records for a single day.
- Record format: TELLERCUSTOMER[TIME]
- TELLER is the teller id
- CUSTOMER is the customer id
- TIME is the time (between 08:00:00AM and 04:00:00PM) the customer stood in the queue or was processed by the teller
- The first occurrence of a record is when the customer stands in the queue; the second occurrence of the same record is when the customer is processed
- [TIME] is absent from the record if the customer leaves the queue without being processed. The input ends with the line ENDOFINPUT, which is not part of the input.
Output
Print the three busiest tellers, the total number of customers each processed in the day, and each one's peak time frame (in hours), one teller per line.
-
Format: TELLERPROCESSED-COUNTPEAK-TIMEFRAME
-
A busy teller is one who processes more customers, not one who has more customers in the queue.
-
If there are multiple time frames with the same peak weight, print the first peak time frame (the one nearest to 08:00:00AM).
-
If two or more tellers processed the same number of customers, sort them by name in ascending order.
-
A TIMEFRAME is 1 hour long. Example: there are 8 time frames between 08:00AM and 04:00PM: 08AM, 09AM, 10AM, ..., 02PM, and 03PM
-
A time frame covers, for example:
- 08:00:00AM <= 08AM time frame < 09:00:00AM
- 03:00:00PM <= 03PM time frame < 04:00:00PM
-
Hint
In this case there are four tellers and ten customers.
- Teller 01 processed 4 customers. Three of them were processed in the 08AM time frame, and one was processed in the 10AM time frame.
- Teller 02 processed 2 customers. Both were processed in the 10AM time frame.
- Teller 03 processed 3 customers. One was processed in the 02PM time frame, and the other two were processed in the 03PM time frame.
- Teller 04 had one customer in the queue, but that customer left the queue.
So the teller with the most processed customers is T01 with four, the second busiest teller is T03 with three, and then T02, which processed two.
Customer 01 (CUST01) stands in teller 01's (T01) queue at [T01 CUST01 08:18:55AM], and is processed at [T01 CUST01 08:22:00AM].