http://blog.sina.com.cn/s/blog_5e518b010100kbts.html //自定义优先级类型 struct cmp { bool operator()(const Node &t1,const Node &t2) { return t1.b<t2.b;//相当于less,大顶堆 } }; //定义优先队列 ,自定义优先级 //,跟Qsort里面自定义相似 priority_queue<Node,vector<Node>,cmp> Q(arr,arr+n);