#C14673. Task Distribution Problem

    ID: 44348 Type: Default 1000ms 256MiB

Task Distribution Problem

Task Distribution Problem

In this problem, you are given a set of tasks, each associated with a workload. Your goal is to distribute the tasks between two workers such that the maximum workload assigned to any worker is minimized. Formally, if worker 1 gets a workload W₁ and worker 2 gets a workload W₂, you want to minimize (\max(W_1, W_2)). You may assign tasks in any order. A binary search approach combined with a greedy check is a common method to solve this problem efficiently.

inputFormat

The input consists of two lines. The first line contains an integer (n) representing the number of tasks. The second line contains (n) space-separated integers, where the (i^{th}) integer denotes the workload required for the (i^{th}) task.

outputFormat

Output a single integer representing the minimum possible value of the maximum workload after distributing the tasks between the two workers.## sample

4
10 7 5 8
15