Since the submarine lost a dept of 350 feet in 20 minutes, we can establish a ratio of (350/20) 17'5 feet lost per minute. This way, we could establish the folloing equation:
y = 400 - 17'5x
where "y" is the depth, and "x" the time passed in minutes since the beginning of the ascension.
The depth five minutes after it started surfacing will be:
y = 400 - 17'5··5 = 312'5 feet