Problem link: https://www.hackerearth.com/codemonksorting/algorithm/monkinthegrassfields/
My code: https://www.hackerearth.com/submission/2962880/
My logic:

Find sum of elements in each row and store in an array called rowsum.

Find sum of elements in each column and store in an array called colsum.

Sort rowsum and colsum

Choose the row sum or column sum with the least value. Let’s say it’s a row which has the least value. Increase that particular row sum by n, and increment all colsum values by 1. Can happen vice versa.

Sort. Repeat.
Might not be the most efficient, but it seems to be wrong as such. I don’t really get the idea described in the editorial in the problem link either. So could someone please clarify why my logic is wrong and in what angle I should approach the problem instead (just a hint)?