Statistics

Problem Statement for "TaskMaster"

Problem Statement

PROBLEM STATEMENT

As the manager of a two-person company, your job is to assign various tasks to
each of your workers.  In order to avoid accusations of unfair employee
treatment, you have decided to assign tasks such that the difference in
workload between the two workers is minimized.

Implement a class TaskMaster that contains a method getDifference.  Given a
int[] representing the number of hours required for each task you would like
completed, assign the tasks such that the difference between the number of
hours required for each employee to complete their tasks is minimized.  The
getDifference method will return this difference.

DEFINITION

Class name: TaskMaster
Method name: getDifference
Parameters: int[]
Returns: int

The method signature is:
int getDifference(int[] tasks);
Be sure your method is public.

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
*tasks can contain between 0 and 12 elements inclusive
*each element of tasks will be between 0 and 100 inclusive


EXAMPLES

tasks - {10, 10}

Each task takes 10 hours, so you can divide them equally between the two
employees.  The difference would be 0 in this case.

tasks - {5, 7, 12, 3}

In this case, one worker can take the 12 hour job and the other can take the 5,
7, and 3 hour jobs.  The difference in workloads would be 3.

tasks - {1, 9, 1, 9, 3, 7, 3, 7}
Output: 0

tasks - {1, 9, 1, 9, 3, 7}
Output: 2

tasks - {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Output: 1

tasks - {10, 11, 7, 7, 7}
Output: 0

Definition

Class:
TaskMaster
Method:
getDifference
Parameters:
int[]
Returns:
int
Method signature:
int getDifference(int[] param0)
(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: