Problem Statement
PROBLEM STATEMENT
Two friends are given a list of tasks to complete for work. The faster they
complete the work, the more they get paid. Since they split the money, they
can do any task from either list in any order.
Create a class Task that contains the method fastest, which takes in the
parameter task1 and task2, both of which have 0 to 5 elements inclusive of
minutes required to complete a task, and returns the minimum time (minutes)
required to finish all tasks assigned.
DEFINITION
Class: Task
Method: fastest
Parameters: int[], int[]
Returns: int
Method signature (be sure your method is public): int fastest(int[] task1,
int[] task2);
TopCoder will ensure the validity of the inputs. Inputs are valid if all of
the following criteria are met:
- task1 and task2 will each have 0 to 5 elements (inclusive)
- each element of task1 and task2 will be an integer between 0 and 200 minutes
(inclusive)
EXAMPLES
1) task1 = {5,2,9} and task2 = {1,1} Method returns 9
The first friend does the first and second task from task1, and both tasks from
task2, which takes 5+2+1+1 = 9 minutes. The other friend does the last task of
task1 in 9 minutes. This is the shortest amount of time possible to complete
all tasks.
2) task1 = {5,2,3} and task2 = {5,2} Method returns 9
One friend gets tasks 5+2+2 = 9, the other gets 5+3 = 8
3) task1 = {10,20,40} and task2 = {1} Method returns 40
One friend gets tasks 10+20+1 = 31, the other gets 40
4) task1 = {5,2} and task2 = {5,2} Method returns 7
5) task1 = {5,5} and task2 = {2,2} Method returns 7
Each friend does a 5 min and 2 min task.Definition
- Class:
- Task
- Method:
- fastest
- Parameters:
- int[], int[]
- Returns:
- int
- Method signature:
- int fastest(int[] param0, int[] param1)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.