You are given a K * K grid that represents a crop field. Choose a straight path that travels from the top row to the bottom row, moving only downward.
Every crop located on the chosen path is destroyed. Crops may be harvested only from cells immediately to the left or right of that path within the corresponding row. For instance, if the path passes through cell (1,1), crops at (1,0) and (1,2) may be collected, but the crop at (2,1) may not be collected because it lies below the path rather than beside it.
Given the field dimension and the crop coordinates, determine the greatest number of crops that can be harvested under these rules.
K: the length of one side of the square K * K matrix.C: a list of crop coordinates, such as [(0,0), (1,2), (3,4)].Return one integer containing the maximum number of crops that can be harvested.
The provided inputs may not be completely accurate. At present, the two example images are intended to provide enough context for understanding the task. Additional input values may be revised later; anyone with further information may contact Groot on the Discord server.
K <= 1 * 10^4Number of crops <= 5 * 10^5Input:
K = 3
C = [[0,1], [0,2], [1,0], [1,1], [2,0]]
Output: 14
This output is the stated maximum harvest for the supplied grid dimension and crop coordinates.