struct cmp { bool operator ()(Pair a,Pair b) //你想要定义的比较函数 { if(a.second-a.first==b.second-b.first) return a.first>b.first; return a.second-a.first<b.second-b.first; } }; priority_queue<Pair,vector<Pair>,cmp>q;