Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 433 |

@iamronak | 424 |

@imnm | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

Dilpreet wants to paint his dog**- **Buzo's home that has **n** boards with different lengths[A1, A2,..., An]. He hired **k** painters for this work and each painter takes **1 unit time to paint 1 unit of the board.**The problem is to find the minimum time to get this job done under the constraints that any painter will only paint continuous sections of boards, say board {2, 3, 4} or only board {1} or nothing but not board {2, 4, 5}.

**Input:**

The first line consists of a single integer **T**, the number of test cases. For each test case, the first line contains an integer **k **denoting the number of painters and integer **n **denoting the number of boards. Next line contains n- space separated integers denoting the size of boards.

**Output:**

For each test case, the output is an integer displaying the minimum time for painting that house.

**Constraints:**

1<=T<=100

1<=k<=30

1<=n<=50

1<=A[i]<=500

**Example:
Input:**

2

2 4

10 10 10 10

2 4

10 20 30 40

20

60

**Explanation:
1.** Here we can divide the boards into 2 equal sized partitions, so each painter gets 20 units of the board and the total time taken is 20.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
The Painter's Partition Problem

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.