vector<int> bucket(1000001);
void bsort(vector<int>& arr) {
    fill(bucket.begin(), bucket.end(), 0);
    for (int i = 0; i < arr.size(); ++i)
        ++bucket[arr[i]];
    for (int i = 0, tot = 0; i < bucket.size(); ++i)
        for (int j = 1; j <= bucket[i]; ++j)
            arr[tot++] = i;
}

发表回复