Loading...
Loading...
The college has one seminar room, and n clubs want it on the same day. Meeting i starts at minute start and ends at minute end. The room is busy from the start minute up to the end minute, and free again at the end minute. So a meeting that ends at minute 5 and a meeting that starts at minute 5 can both use the room.
The student council can say yes to some meetings and no to the rest. Two accepted meetings must never be in the room at the same time. Print the largest number of meetings the council can accept.
start end for one meeting.Example
Input
6 1 4 3 5 0 6 5 7 8 9 5 9
Output
3
Accept 1 4, 5 7 and 8 9. Every other meeting overlaps one of these, and no four meetings fit together.
Try the problem first. Open one hint at a time.
Think about which meeting should be the first one you accept.
The first accepted meeting should leave the room free as early as possible.
Sort the meetings by end time. Go through them and accept a meeting when it starts at or after the end of the last accepted one.
A meeting that starts exactly when the last one ends is allowed, so compare with >=.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor