Statistics

Problem Statement for "TimeTeam"

Problem Statement

PROBLEM STATEMENT

TopCoder wishes to expand its contests to include team effort. Teams are given
a set of tasks to work on, with each earning points based on the total amount
of time the team as a whole spent working on each task. When a team member
works on a task, the task id, the start time, and the stop time are recorded.
Start time and stop time are recorded as the number of seconds since the
contest started.

Your assignment is to calculate the task times for a single team. A task time
is the amount of time during the contest that one or more team members were
working on the task. For example, if Foo works for 10 seconds on task 1, and
later Bar works for 10 seconds on task 1, the total time for task 1 is 20
seconds. But if both Foo and Bar work simultaniously on task 1 for 10 seconds,
the time for task 1 is just 10 seconds.  If no team members worked on a task,
the time for that task is 0.

To determine the task times, you are given the total number of tasks and when
different team members were working on the various tasks. The task id, start
time, and stop time are combined in a single string with the format "T SSS
EEE", where T is a single digit task id (0-9), SSS is the start time (000-998),
and EEE is the end time (001-999).  Both start time and end time must have
exactly 3 digits.  There is one space between the task id and the start time,
and there is one space between start time and end time.

return the times in an int[] using the task id as the index (for instance, task
0 is the first element).

DEFINITION

Class Name: TimeTeam
Method Name: teamTimes
Parameters: int, String[]
Returns: int[]

Method signature (be sure your method is public): int[] teamTimes(int
taskCount, String[] taskData);

taskCount - total number of tasks that may have been worked on.  The return
int[] will have a size equal to taskCount.
taskData - String[] of tasks and when they were worked on.
Each String is formatted as follows (quotation marks are included for clarity
only)
 "task start end"
 task is a single digit 0-9
 start and end are both three digit numbers 000-999
 Example: "9 000 999"
return int[] of task times.  There must be taskCount elements.

TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met:
* taskCount is between 1 and 10, inclusive.
* taskData has between 0 and 50 elements, inclusive.
* the format of each taskData string is "task start end".  Where task is a
single digit (0-9), there is 1 space separating task and start, start is 3
digits (000-998), there is 1 space separating start and end, and end is 3
digits (001-999).
* the value of task is less than taskCount.
* the value of start is less than the value of end.


Example 1:
Two team members, one task.  One team member worked from time 0, to time 20.
The other worked from time 5, to time 25.

taskCount = 1
taskData  = { "0 000 020", "0 005 025" }

At time 0, one team member started working on task 0.
At time 5, another team member joined the work.
At time 20, the first team member stopped working, but the second continued
working.
At time 25, the other team member also stopped working.

Since there was at least one team member working on task 0 from time 0 to time
25,
the team time for task 0 is 25.

return { 25 }


Example 2: 
taskCount = 3
taskData  = { 
	"0 000 300", 
	"1 300 800", 
	"0 850 900", 
	"0 000 020", 
	"1 020 200", 
	"0 200 500" }

return { 550, 680, 0 }

Example 3:
taskCount = 10
taskData = { }
return { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }

Example 4:
taskCount = 4
taskData = { "3 998 999", "2 002 007", "3 997 998", "1 002 006", "3 996 998" }
return { 0, 4, 5, 3 }

Example 5:
taskCount = 1
taskData = { "0 000 010", "0 010 100" }
return { 100 }

Example 6:
taskCount = 1
taskData = { "0 000 100", "0 010 100" }
return { 100 }

Definition

Class:
TimeTeam
Method:
teamTimes
Parameters:
int, String[]
Returns:
int[]
Method signature:
int[] teamTimes(int param0, String[] param1)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: