Company: Zorvyn SDE_4april
Difficulty: medium
You are managing a data center with N tasks that need to be assigned to K servers. Each task i has a processing load of L[i] units. Tasks must be assigned in contiguous groups to servers. That is, you partition the array of tasks into K contiguous segments, and each segment is assigned to one server. The load on a server is the sum of processing loads of all tasks assigned to it. You want to minimize the maximum load on any server. Find the minimum possible value of the maximum load on any server. Input Format First line contains two space-separated integers N and K . Second line contains N space-separated integers representing loads L[1], L[2], ..., L[N] . Output Format Print a single integer - the minimum possible maximum load on any server. Examples Example 1 Input: 5 2 1 2 3 4 5 Output: 9 Explanation: Optimal partition: [1, 2, 3] and [4, 5] Server 1: 1+2+3 = 6 Server 2: 4+5 = 9 Maximum load = 9. Example 2 Input: 6 3 10 20 30 40 50 60 Output: 90 Explanation: Optimal partition: [10,