Can conservation of energy be applied if trajectory is not smooth? In this video
http://www.khanacademy.org/video/conservation-of-energy?playlist=Physics
Khan academy explains conservation of energy for a falling object. He looks at an object falling perpendicularly from height h and computes its velocity at height zero. So far so good. But then he draws a curve that has several variations in height such that the object needs to climb back to certain height before falling back. At the end he computes again the velocity of the object and finds the same as object falling on the perpendicular.
Intuitively this seems wrong to me. To simplify his drawing I drew this picture:

I reason like this: The object falls to C but then it needs to climb back up to D and at D its vertical velocity is zero (because it changes direction, but not sure if this correct). So at B the velocity will be as if the object fell from D not from E. Is this correct? What is the best way of thinking about this problem?
 A: Assuming your diagram here is something like a ball rolling down a hill or a bead sliding on a wire (ignoring friction of course), you are right to say that the vertical velocity at D is 0, but this is irrelevant for the energy. What is relevant is the total velocity, and at D the total velocity there will be entirely horizontal, and given by the height difference $h_E - h_D$. For a simplifying example, consider a ball rolling down a quarter-pipe onto a flat surface. When the ball reaches the bottom, it has no vertical velocity, but only horizontal. The horizontal velocity will have the same magnitude as the veritcal velocity of a ball dropped straight down (with no intervening surface) from the same height.
A: If the radius of curvature R at point D satisfies
$$v^2/R > g$$
(gravity is insufficient centripetal force) where v is the velocity computed from the conservation of energy, the sliding object will leave the ramp. This is why your intuition is upset-- if the object is moving fast enough, and the ramp is not sufficiently slowly curving, gravity will not keep the sliding object on the ramp. In the picture, the point D has a pretty small looking R.
Answering the title question
The title question is much more interesting than the example--- can energy be conserved when the constraints are non-differentiable? The answer is no, and a simple example is a cylinder that hits a step bump, and rises up.
Conservation of angular momentum at the contact point requires that if the cylinder doesn't bounce off, it loses energy at the bump. This is also true in other constrained systems with non-differentiable constraints, and the amount of energy loss is readily calculable from conservation principles alone, just from the form of the non-differentiability. This is a common olympiad style exercize in physics.
