P2094运输
--------------------
链接:Miku
-------------------
这是一道水贪心,很容易想到做法就是把最贵的两个放在一块,让后当成一个重新放回队列
-------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<algorithm> #include<cstdio> #include<queue> using namespace std; priority_queue <int,vector<int>,less<int> > q; //bool operator < (int x,int y){ // return x>y; //}; int n,k; int x; int main(){ scanf("%d%d",&n,&k); for(int i=1;i<=n;++i){ cin>>x; q.push(x); } while(1){ int x=q.top(); q.pop(); int y=q.top(); q.pop(); q.push((x+y)/k); if(q.size()==1){ cout<<q.top(); return 0; } } return 0; }