I have been trying this problem, My approach is to do two dfs.
First one to determine, if from a cell water can get out of the board following smaller height/equal height cubes.
In second one, I find the smallest height of the surrounding, I call it wall. Then, for each connected water region I check if this cube has height smaller than wall, then I add (wall-current height) to ans.
Getting WA repeatedly. Need some tricky cases where my solution may fail.