CodeChef: April Long Challenge | Worthy Matrix | KAVGMAT | Solution

View on Codechef Chef found a matrix AA with NN rows (numbered 11 through NN) and MM columns (numbered 11 through MM), where for each row rr and column cc, the cell in row rr and column cc (denoted by (r,c)(r,c)) contains an integer Ar,cAr,c. This matrix has two interesting properties: The integers in each row form a non-decreasing sequence, i.e. for each valid ii, Ai,1≤Ai,2≤…≤Ai,MAi,1≤Ai,2≤…≤Ai,M. The integers in each column also form a non-decreasing sequence, i.e. for …

CodeChef: April Long Challenge | Worthy Matrix | KAVGMAT | Solution Read More »