County Fair Events
Time limit2sMemory limit512 MB
Given N intervals, find the maximum number of non-overlapping intervals John can attend.
Problem
Farmer John is back at the county fair, where special events are held: concerts, rodeos, cooking shows, and the like. He wants to attend as many of them as he can.
He rented a bicycle, so moving from one event to the next takes no time at all.
Event starts at time and runs for time units, so it ends at time . John never leaves an event early, so attending an event means staying from its start to its end. If one event ends at the same moment another starts, he can attend both.
Determine the largest number of events John can attend.
Input
The first line contains the number of events ().
Each of the next lines contains two integers and separated by a space, the start time and the duration of one event (, ).
Output
Print on the first line the largest number of events John can attend.