#K65872. Maximum Movies Scheduling
Maximum Movies Scheduling
Maximum Movies Scheduling
You are given a set of test cases. In each test case, there are a number of movies, each with a starting time and a duration. Your task is to determine the maximum number of movies one can watch without any overlapping. A movie with starting time (s_i) and duration (d_i) finishes at time (f_i = s_i + d_i). Two movies do not overlap if the start time of a movie is greater than or equal to the finish time of the previously watched movie. Use a greedy strategy: sort the movies by their finish time and then select movies accordingly.
inputFormat
The first line contains an integer (T) denoting the number of test cases. For each test case, the first line contains an integer (N) representing the number of movies. This is followed by (N) lines, each containing two space-separated integers: the starting time and the duration of a movie.
outputFormat
For each test case, print one line containing a single integer representing the maximum number of movies that can be watched without overlapping.## sample
2
3
1 3
2 2
4 1
4
0 5
3 3
6 1
8 2
2
3
</p>