构造一个大顶堆
priority_queue<int,vector<int>,less<int>> big_heap;
构造一个小顶堆
priority_queue<int,vector<int>,greater<int>> small_heap;
多个元素
struct Node {
int amount;
int prices;
};
struct cmp1 {
bool operator () (const Node &a, const Node &b) {
return a.prices < b.prices;
}
};
struct cmp2 {
bool operator () (const Node &a, const Node &b) {
return a.prices > b.prices;
}
};
priority_queue<struct Node, vector<struct Node>, cmp2> sell_que; // 小顶堆
priority_queue<struct Node, vector<struct Node>, cmp1> buy_que; // 大顶堆