Consistent Algorithms for Clustering Time Series