Get nearest centroid using Thrust library? (K-Means)

I computed the distances and stored in a thrust vector, for instance, I have 2 centroids and 5 datapoints and the way I computed the distances was that for each centroid I computed the distances with the 5 datapoints first and stored in the array and later with the other centroid in a 1d array in distances, just like this:

for (int i = 0; i < centroids.size(); ++i)
{
computeDistance(Data, distances, centroids[i], nDataPoints, nDimensions);
}

Resulting in a vector 1d, for instance:

DistancesValues = {10, 15, 20, 12, 10, 5, 17, 22, 8, 7}

DatapointsIndex = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5}

Where the first 5 values represent centroid 1 and other 5 values centroid 2.

What I would like to know if there is a thrust function in which I can store the count in another array of the minimum values for each centroid?

Comparing the values of each index, Result should be:

Counts = {2, 3}

where:

CountOfCentroid 1 = 2
CountOfCentroid 2 = 3

thanks!