CF 1741C - Minimize the Thickness

We are given an array of positive integers and asked to partition it into consecutive segments such that all segments have the same sum. Each segment must be contiguous, and each element belongs to exactly one segment.

CF 1741C - Minimize the Thickness

Rating: 1100
Tags: brute force, greedy, math, two pointers
Solve time: 2m 39s
Verified: no

Solution

Problem Understanding

We are given an array of positive integers and asked to partition it into consecutive segments such that all segments have the same sum. Each segment must be contiguous, and each element belongs to exactly one segment. The thickness of a split is the length of the largest segment, and the goal is to minimize this thickness.

The constraints are moderate: the array length per test case is at most 2000, and the total across all test cases is also bounded by 2000. This allows an algorithm with worst-case time complexity around $O(n^2)$ per test case, since $2000^2$ operations are acceptable within a 2-second limit.

Non-obvious edge cases include arrays that cannot be split evenly except by taking the entire array as one segment, for example, an array like `[10, 23, 7,