The optimal allocation of time and respiratory metabolism over the dive cycle