Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

Given an array/list of length * ‘n’*, where the array/list represents the boards and each element of the given array/list represents the length of each board. Some

You are supposed to return the area of the minimum time to get this job done of painting all the ‘n’ boards under a constraint that any painter will only paint the continuous sections of boards.

```
Input: arr = [2, 1, 5, 6, 2, 3], k = 2
Output: 11
Explanation:
First painter can paint boards 1 to 3 in 8 units of time and the second painter can paint boards 4-6 in 11 units of time. Thus both painters will paint all the boards in max(8,11) = 11 units of time. It can be shown that all the boards can't be painted in less than 11 units of time.
```

Detailed explanation

```
4 2
10 20 30 40
```

```
60
```

```
In this test case, we can divide the first 3 boards for one painter and the last board for the second painter.
```

```
2 2
48 90
```

```
90
```

```
Try to do this in O(n*log(n)).
```

```
1 <= n <= 10^5
1 <= k <= n
1 <= arr[i] <= 10^9
Time Limit: 1 sec.
```