if the remaining capacity of water for curr glass is greater than then the remaining capacity of tatal water then we put all remaining water into curr glass
if ( rem_water > curr . rem_water ) { dp [ curr . row ] [ curr . col ] += curr . rem_water ; curr . rem_water = 0 ; } else { dp [ curr . row ] [ curr . col ] += rem_water ; curr . rem_water -= rem_water ; } }