Similar Items: An Optimal Algorithm for Cardinality-Constrained Diameter Partitioning