Under construction

Still being built. Things may change

We Want You Happy!

Interview

Time limit5sMemory limit1024 MB

Summary
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 (1≤n≤1031 \le n \le 10^3), 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 10410^4, inclusive),
  • service time (an integer between 1 and 10410^4, inclusive), the time the teller needs to process this customer once the customer is at the teller,
  • patience time (an integer between 1 and 10410^4, 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.

Examples1

  1. Example 1

    Input
    7
    1 50 10 5
    2 52 5 4
    3 58 20 5
    4 85 7 10
    5 86 10 1
    6 88 20 3
    7 89 30 3
    
    Expected output
    1
    3
    4
    7