#P1973. [NOI2011] NOI 嘉年华
[NOI2011] NOI 嘉年华
Description
NOI 2011 has started at Jilin University! To welcome the best informatics contestants from across the country, Jilin University plans to hold two grand NOI Carnival events at two different locations. Each carnival may contain many activities, and each activity can be held in only one carnival.
The organizer, Xiao An, has received applications for activities. The -th activity starts at time and lasts for time. These activities can be scheduled in either carnival, or not scheduled at all.
Through extensive surveys, Xiao An found that if, at some moment, the two carnivals have activities running simultaneously (not counting the exact start and end instants), some contestants will hesitate about which carnival to go to and become unhappy. Therefore, to avoid this, Xiao An requires that there must not be two activities running at the same time in the two different carnivals (activities within the same carnival may overlap arbitrarily).
In addition, if one carnival has too few activities, its appeal will be insufficient and the scene may become dull. So Xiao An wants to arrange the schedule to maximize the number of activities in the less-populated carnival.
Furthermore, some activities are very meaningful and Xiao An hopes to hold them. He wants to know, if the -th activity must be held (it can be scheduled in either of the two carnivals), what is the maximum number of activities in the less-populated carnival.
Input Format
The first line contains an integer , the number of activity applications.
The next lines describe all activities. The -th line contains two integers , meaning the -th activity starts at time and lasts for time.
Output Format
The first line contains an integer, the maximum number of activities in the less-populated carnival when there are no additional constraints.
Then output lines, one integer per line. The integer on the -th line is the maximum number of activities in the less-populated carnival under the condition that the -th activity must be chosen.
5
8 2
1 5
5 3
3 2
5 3
2
2
1
2
2
2
Hint
Sample Explanation
Without any additional constraints, an optimal arrangement is to schedule activities in one carnival and activities in the other carnival, leaving activity unscheduled.
For 10% of the testdata, .
For 30% of the testdata, .
For 100% of the testdata, , , .
If the output format is incorrect (for example, fewer than lines), the score is . If the first line of the output file is incorrect, and at least one of the last lines is also incorrect, the score is . If the first line of the output file is correct, but at least one of the last lines is incorrect, the score is . If the first line of the output file is incorrect, but all of the last lines are correct, the score is . If all lines in the output file are correct, the score is .
Translated by ChatGPT 5
京公网安备 11011102002149号