We Want You Happy!
InterviewTime limit5sMemory limit1024 MB
Given arrival, service, and patience times for n customers served in arrival order by one teller, list the customers who are processed without leaving.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Input and output
The United Credit Finance (UCF) is running a simple scenario to see how many customers are happy with the company. UCF has one teller serving the customers. Customers are numbered 1 to n, and they arrive for service in sequential order. Customer 1 arrives first, then Customer 2, then Customer 3, and so on. No two customers arrive at the same time, so Customer 2 arrives later than Customer 1, Customer 3 arrives later than Customer 2, and so on. Customers are processed in the order of arrival.
Some customers get impatient while waiting in line and leave. Given the information about the customers, determine which customers are happy, that is, which customers do not leave before being processed.
Input
The first line contains an integer n (), the number of customers. Each of the next n lines contains information about one customer:
- customer number (1, 2, 3, and so on, in sequential order),
- arrival time (an integer between 1 and , inclusive),
- service time (an integer between 1 and , inclusive), the time the teller needs to process this customer once the customer is at the teller,
- patience time (an integer between 1 and , inclusive), the time the customer waits in line before giving up. If the customer is not at the teller when this time runs out, the customer leaves. A customer who leaves is not processed, so the customer takes no time from the teller.
Output
Print the happy customer numbers in sequential order. A happy customer is one who was processed and did not leave.