Problem with stl sort compare function

I was trying to solve this problem on spoj -http://www.spoj.com/problems/BUSYMAN/

wherein my algorithm required to sort the array according to their ending times.(i.e One ending first must come before in the array).

This is what I tried-

But the code gives runtime eorror (SIGSEGV) on spoj.

Just to see if there was something wrong with my comparator function I now modified the code to this one-

(same logic but avoiding the use of the comparator function)
And this one got ACCEPTED!

what makes the first one go wrong??