Witnessing entanglement of continuous-variable systems based on their dynamics