I'm preparing for the next hashcode by solving the following prev. problem:
Given a pizza of size R x C with cells containing either mushrooms or tomatoes as shown bellow:
We are given 2 parameters:
H. The goal is to split the pizza into rectangular slices such that each rectangle contains at least
L cells of mushrooms and at least
L of tomatoes. Furthermore, each split rectangle should contain at most
H cells in total. Note that not all of the pizza needs to be contained in the split. The goal is to maximize the number of cells
So in the example above,
H=6 so in this case The ideal split will be:
So each split contains at least 1 mushroom and at least 1 tomato, and each split contains at most 6 cells. I am not sure how to approach the solution to this problem? Which topics should I read about to understand how to solve such a problem?
P.S. I'm not sure what tags to add for this problem but I will add the appropriate tags and title once I receive guidance.