priority_queue优先队列
priority_queue <int> que;//默认从大到小
priority_queue < int,vector<int>,greater<int> > que;//从小到大
int main()
{
int n,a;
cin>>n;
for(int i = 0; i < n; i++)
{
cin>>a;
que.push(a);
}
while(!que.empty())
{
cout<<que.top()<<endl;
que.pop();
}
return 0;
}
结构体
struct node
{
int x,y;
bool operator < (const node & a) const
{
return x > a.x;//按x从小到大排列
}
};
priority_queue <node> q;