The levels of water from the see bottom are indicated in the left of the diagram and the equilibrium point of the simple harmonic motion (y=0) and the positions as measured from this point are shown on the right. The red line is the critical sea level below which the ship shouldn’t be in the harbor (y = -3 m).

The equation for the SHM with the initial condition y = -A (amplitude) at t =0 is given by:

 y= -A cos{(2p/T) t}; the level y of the sea as a function of time t. I hope you understand that the y coordinate should have the origin at the equilibrium point to use this equation.

With this formulation of the problem you can say the physics part of the problem is almost over; what follows is Mathematics. But Mathematics is the tool that every scientist worth the name should be well equipped with.