#C3363. Distributing Tasks to Minimize Maximum Server Load

    ID: 46782 Type: Default 1000ms 256MiB

Distributing Tasks to Minimize Maximum Server Load

Distributing Tasks to Minimize Maximum Server Load

You are given S identical servers and N tasks. Each task has a processing time. Your goal is to distribute all tasks among the servers so that the maximum load (processing time) assigned to any server is minimized.

Formally, given a list of tasks with processing times \( t_1, t_2, \dots, t_N \), you need to assign each task to one of the \( S \) servers. For a given server, the load is the sum of processing times of tasks assigned to it. You are required to determine the smallest possible value \( L \) such that the tasks can be distributed among the servers where no server has a load greater than \( L \).

Input/Output details: Read the input from standard input and print the output to standard output.

inputFormat

The first line contains two integers \( S \) and \( N \), where \( S \) is the number of servers and \( N \) is the number of tasks. The second line contains \( N \) integers representing the processing time of each task.

For example:

4 6
10 20 30 40 50 60

outputFormat

Output a single integer, the minimized maximum processing time among all servers after optimally distributing the tasks.

For the sample input above, the output would be:

60
## sample
4 6
10 20 30 40 50 60
60