class Solution {
public:
vector<int> smallerNumbersThanCurrent(vector<int>& nums) {
vector<pair<int,int>>tmp(nums.size());
for(int i = 0; i < nums.size(); i++)
{
tmp[i] = make_pair(nums[i], i);
}
sort(tmp.begin(), tmp.end());
vector<int>res(nums.size(), 0);
for(int i = 1; i < tmp.size(); i++)
{
if(tmp[i-1].first < tmp[i].first)
{
res[tmp[i].second] = i;
}
else
{
res[tmp[i].second] = res[tmp[i-1].second];
}
}
return res;
}
};