#P3626. Meeting Center Rental Scheduling

    ID: 16877 Type: Default 1000ms 256MiB

Meeting Center Rental Scheduling

Meeting Center Rental Scheduling

The Siruseri government has built a new conference center. Many companies are interested in renting the hall to hold meetings. A company will rent the hall only if it can have the hall exclusively during its meeting. The sales manager wishes to rent the hall to as many companies as possible. However, if there are several ways to achieve the maximum number of non-overlapping meetings, the final strategy is chosen as follows: first, consider only strategies with the maximum number of companies; then, assign each company an index in the order they sent their request (starting from 1); next, sort the indices of the companies in each strategy in ascending order; finally, select the strategy whose sorted sequence of company indices is lexicographically smallest.

For example, suppose there are 4 companies with the following meeting requests:

  • Company 1: Start = 4, End = 9
  • Company 2: Start = 9, End = 11
  • Company 3: Start = 13, End = 19
  • Company 4: Start = 10, End = 17
Note that two meetings conflict if they share any day (i.e. if one meeting ends on day X and another begins on day X, they conflict). In the example, at most two companies may have non-overlapping meetings. The candidate strategies are { (1,3), (2,3), (1,4) } and, because (1,3) is lexicographically smallest (when both sequences are sorted in ascending order), the hall is ultimately rented to companies 1 and 3.

inputFormat

The first line contains an integer nn (1n1051 \le n \le 10^5), the number of companies. Each of the next nn lines contains two integers ss and ee (1s,e1091 \le s,e \le 10^9) which denote the start and end days (inclusive) of the meeting request. Two meetings conflict if they share a common day.

outputFormat

Output a single line containing the indices (as given in the input order, starting from 1) of the companies that will rent the hall. The indices must be output in ascending order, separated by single spaces.

sample

4
4 9
9 11
13 19
10 17
1 3