Set
zzr8178541919 · · 个人记录
set<int> s;
set<int>::iterator it;
求区间第k小:
for(reg int i=1;i<=n;i++)
{
int x=read();
s.insert(x);
}
int tot=0;
for(it=s.begin();it!=s.end();it++)
{
tot++;
if(tot==k)
{
cout<<*it<<endl; // the value
return 0;
}
}
解释: