Solve this one too
Time limit5sMemory limit512 MB
Given an N x L matrix, find windows of 3N columns split into matrices A, B, C with A*B=C; pick disjoint windows to maximize total colored cells.
- Level
Hard9 of 10
- Topics
- Matrix, Dynamic programming, Intervals, Math
- Solved
- No attempts yet
Problem
You are given an integer matrix with rows and columns. Take consecutive columns of and cut them into three matrices, columns at a time from the left. Call them , and in that order. If holds, you may color that region.
If even one cell of the region you want to color is already colored, you cannot color that region. Choose the coloring order so that as many numbers as possible get colored, and find that maximum count.
Input
The first line contains two integers and . (, )
Each of the next lines contains one row of . The -th integer on the -th of those lines is . ()
Output
Print the maximum number of numbers that can be colored.