← All problemsSign in

Chef’s Beautiful Matrix

Chef has a two-dimensional matrix A of dimensions $N × M$, ($N$ rows and $M$ columns). He calls the matrix A beautiful if there exist an $a×b$ submatrix, such that all of its elements are equal. In one minute Chef can increase one element of the matrix A by 1. Now he asks you to find out minimum time he will need to make the matrix A beautiful? Please note that sub-matrix of a matrix is a contin

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start