Hills and rain problem

This program calculates the amount of water which fill pits between hills.