### Problem Statement

So much to do and so little time to do it in! You have a long list of computer programs that must be run and you want them to finish running as soon as possible. Each program in the list requires a certain amount of your time to set up, and during this time you must devote your full attention to the setup of that program. After you have finished with the setup of a program, it will immediately start execution and will run for a certain amount of time on the computer. You have enough processing power that all of the programs may be run simultaneously without any of them slowing down. You are to find a schedule such that the time at which all of the programs are finished is as early as possible and you should return that time (assuming you start at time 0).

You will be given int[]'s A and B, corresponding elements of which represent a single program. Each element of A represents the setup time of a program and the corresponding element of B represents the running time of that program.

### Definition

 Class: ProgramSchedule Method: schedule Parameters: int[], int[] Returns: int Method signature: int schedule(int[] A, int[] B) (be sure your method is public)

### Constraints

-A and B will contain the same number of elements.
-A and B will contain between 1 and 50 elements, inclusive.
-Each element of A and B will be between 1 and 1000, inclusive.

### Examples

0)

 ```{1,2,3,4} ``` `{2,2,4,2}`
`Returns: 12`
 In this case, you can simply execute the programs in the same order they are given (though there are other ways which give the same final time). The 4 programs will finish after 3, 5, 10, and 12, respectively.
1)

 `{3,1,2}` `{4,3,9}`
`Returns: 11`
2)

 `{1000}` `{1000}`
`Returns: 2000`

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3945

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6520&pm=3945

lars2520

#### Testers:

PabloGilberto , lbackstrom , brett1479

Greedy, Sorting