The force acting on a body depends on the displacement $x(t)$ of the body from the origin. This dependence is given by
$$ F(x) = \begin{cases} F_0 - mg, &-L < &x < 0,\\ -mg,& &x > 0. \end{cases} $$
where $L$ is a positive number, $F_0 > 0$ is a constant resting force and $g$ is the gravitational acceleration of Earth.
Newton's second law gives $m\ddot{x} = F(x)$ and we impose the initial conditions $\dot{x}(0) = 0, x(0) = -L.$
How does one solve an equation like this? My main problem is that if we restrict to the branch $x > 0$ we get $x = -g\frac{t^2}{2} + At + B$. I don't know if I am allowed to plug in the boundary conditions here, but if I were to, I would get $x = -g\frac{t^2}{2} - L$. But this function is clearly always negative, so then how could this satisfy the branch $x>0$?
Any tips or clarifications?
You just have to solve two ODE's. First solve the ODE for $x\in[-L,0)$ using your initial conditions $\dot{x}(0)=0$, $x(0)=-L$. That equation is valid until $x=0$. Then you can get values of $\dot{x}$ for when $x=0$. That is your new initial condition to use when solving the second ODE.