v0.01 which is giving the correct total length. BUT, need to do the right backtracking.
UVa inputs
UVa + 1 of mine
UVa + 1 of mine
AC code. Key things:
1. Sort the input
2. Don't print extra newline at the end.