ONEKING and activity selector algorithm

i used a similar activity selector algorithm given in cormen… but i got wrong answer… here is the link to my solution http://www.codechef.com/viewsolution/5754242 plz explain why this algorithm can’t be implemented…

Please Check your code…

Input:

  1
  4
  1 3
  4 2
  5 5
  6 5

Anwer is 2 but your code gives 3. :wink: