TopCoder problem "OlympicsBroadcasting" used in TCCC06 Semi 2 (Division I Level One)

Problem Statement


You are running a TV network that has the rights to transmit the olympic games. The network is going to create several channels that transmit events of the games continuously. Few rules have been established for these new channels:

  • Each event cannot be transmitted on more than one channel
  • Any part of an event may be included in the scheduled programming, even if the beginning and/or the end of it are excluded, but at most one interval of the event can be shown
  • Each channel must have a continuous transmission

You will be given the schedule of the olympics in 2 int[]s startingTime and endingTime, with the ith element of startingTime and endingTime representing the starting and ending time of the ith scheduled event in a special time unit (each interval contains both endpoints, see examples for further clarification). The duration of the games is exactly totalUnits of this time units, which means that the transmition of all the created channels must start at time 0 and end at time totalUnits. Return the maximum number of channels that can be created while satisfying these network policies.



Parameters:int[], int[], int
Method signature:int getMaxChannels(int[] startingTime, int[] endingTime, int totalUnits)
(be sure your method is public)


-startingTime will have between 1 and 50 elements, inclusive.
-startingTime and endingTime will have the same number of elements.
-totalUnits will be between 1 and 1000000000 (109), inclusive.
-Each element of startingTime and endingTime will be between 0 and totalUnits, inclusive.
-The ith element of endingTime will be greater than the ith element of startingTime.


Returns: 2
We can make 2 channels:
  1. Event with index 0 from time 0 to time 2 and event 2 from 2 to 3.
  2. Event with index 4 from time 0 to time 3.
Returns: 1
Returns: 1
Returns: 0
There is no way to cover the 3-4 interval.

Problem url:

Problem stats url:




PabloGilberto , brett1479 , Olexiy , Jan_Kuipers

Problem categories:

Greedy, Sorting