glow's blog

By glow, history, 18 months ago, In English

Given a positive integer array partition array into M subarray such that when we take sum of each subarray and chose maximum it is minimal across all subarray combinations.

I tried drawing all combinations when M=1, M=2... but couldn't find DP pattern. Some help will be greatly appreciated.

Input array : [7,2,3,4,5] and M = 3
Optimal partitioning : [7], [2,3,4], [5]
Answer Max(7, 2+3+4, 5) = 9

Input array : [4,3,2,2,2,6] and M = 3
Optimal partitioning : [4,3], [2,2,2], [6]
Answer Max(4+3, 2+2+2, 6) = 7
Tags dp
  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
18 months ago, # |
  Vote: I like it 0 Vote: I do not like it

This should be the exact same problem. Hint: binary search