// C++ VersionconstintN=100010;intn,w,a[N];vector<int>bucket[N];voidinsertion_sort(vector<int>&A){for(inti=1;i<A.size();++i){intkey=A[i];intj=i-1;while(j>=0&&A[j]>key){A[j+1]=A[j];--j;}A[j+1]=key;}}voidbucket_sort(){intbucket_size=w/n+1;for(inti=0;i<n;++i){bucket[i].clear();}for(inti=1;i<=n;++i){bucket[a[i]/bucket_size].push_back(a[i]);}intp=0;for(inti=0;i<n;++i){insertion_sort(bucket[i]);for(intj=0;j<bucket[i].size();++j){a[++p]=bucket[i][j];}}}