There are
tasks waiting in line to be executed. The execution time for the task is seconds.
Chef has two processors to execute these tasks. Both these processors work simultaneously. Each processor executes the assigned tasks one by one.
Chef assigns a prefix of these tasks to the first processor and the remaining tasks to the second processor.
For example, if there are tasks, Chef can do one of the following:
- Assign no task to the first processor. This means, the second processor will execute tasks and .
- Assign task to the first processor. This means, the second processor will execute tasks and .
- Assign tasks and to the first processor. This means, the second processor will execute task .
- Assign tasks and to the first processor. Thus, second processor would execute no tasks.
Find the minimum time in which all the tasks can be executed.
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- The first line of each test case contains a single integer , the number of tasks waiting to be executed.
- The second line of each test case contains space separated positive integers denoting the execution time for each task.
Output Format
For each test case, output in a single line, the minimum time in which all tasks can be executed.
Constraints
- The sum of over all test cases is not more than .
Subtasks
Subtask #1 (100 points): original constraints
Sample Input 1
3
3
4 2 3
6
1 1 1 1 1 1
1
5
Sample Output 1
5
3
5
Explanation
Test Case 1: Chef assigns task to the first processor and tasks and to the second processor. The first processor takes seconds to execute task . The second processor takes seconds to execute tasks and . Thus, atleast seconds are required to execute all tasks.
Test Case 2: Chef assigns tasks and to the first processor. Processes ad are executed by second processor.
Test Case 3: Chef assigns task to the first processor. No task is executed by second processor.
No comments:
Post a Comment