Prepare

离散化

m = a.y
sort(m+1,m+n+1)
len = unique(m,m+n+1) - m
for (int i=1;i<=n;++i) a[i].y = lower_bound(m+1,m+len+1,a[i].y) - m;

C++技巧

std::copy(begin,end,des)
std::reverse(begin,end)