Need a help!

Revision en5, by AloWarshik, 2025-01-30 12:29:34

I was solving IZhO task on oj.uz platform and i met a DP problem. I've never solved such problem, so i was confused about solution.

The statement:

We have an array A (1 ≤ Ai ≤ 1000000) with size N (1 ≤ N ≤ 100000) . And we need to divide array into exactly K (1 ≤ K ≤ min(N, 100)) blocks, so the sum of maximums in each block is minimized. Sample:


Input: 6 3 5 3 1 2 4 2 Output: 10 Blocks (1, 2), (3, 3), (4, 6)

I solved it for N * N * K using dp[i][x] with transition to every dp[j][x + 1] (i + 1 <= j <= n); my solution

And i looked for editorial but i didn't find it and i looked for full solution from submissions but i didn't understand it. If you can clearly explain how to solve it and prove it, please help.

task link

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English AloWarshik 2025-01-30 12:29:34 0 (published)
en4 English AloWarshik 2025-01-30 12:25:49 0 (saved to drafts)
en3 English AloWarshik 2025-01-30 12:25:03 0 (published)
en2 English AloWarshik 2025-01-29 16:18:33 8 (saved to drafts)
en1 English AloWarshik 2025-01-29 15:13:57 893 Initial revision (published)