A wall in Codetikki consists of several rows of bricks of various integer lengths and uniform height. Find a vertical line from top to bottom that cuts through the fewest bricks. If the line passes through the edge between two bricks, it does not count as a cut. Given a wall as a list of rows (each row is a list of brick lengths), output the minimum number of bricks that must be cut. Input: first line n (number of rows), then n lines each starting with row length k followed by k brick lengths. Output: minimum cuts.
Example 1:
Example 2:
Constraints:
1 <= n <= 10^4 1 <= sum of brick lengths per row <= 10^4 1 <= brick length <= 10^4 All rows have the same total width
Tags:
