RobloxOA #3
Maximum Sum of Rhombic Area
Estimated MediumJudge-ready
Topics (AI-labelled)Prefix & RangesSimulation
The rhombus region of radius r is the set of cells whose Manhattan distance to the center plus one does not exceed r, that is, |row difference|+|column difference|<r. Considering only centers whose entire rhombus lies inside the matrix, find the maximum of these region sums.
Input
The first line contains rows cols radius; then rows lines of the matrix follow. Ranges added by this site: 1≤rows,cols≤200, 1≤radius≤200, |cell|≤10^6. If no complete rhombus exists, output 0.
Output
Output the maximum region sum; when the radius is so large that no complete region exists, output 0.
Example 1
Input:
6 6 3
0 2 4 1 6 4
5 1 3 4 1 5
0 1 2 1 2 1
1 3 2 1 1 2
4 1 3 6 5 5
6 7 5 3 1 2
Output:
35
Example 2
Input:
1 1 1
5
Output:
5
Example 3
Input:
2 2 3
1 2
3 4
Output:
0
Editorial
Loading solution…