题解 | 小红的口罩 | 优先队列贪心
小红的口罩
https://www.nowcoder.com/practice/fde642522d664b49a10fe9de51686026
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n,k,a,ans=0;
priority_queue<int> pq;
cin>>n>>k;
while(n--)cin>>a,pq.push(-a);
while(k>=-pq.top())ans++,k-=-pq.top(),pq.push(pq.top()*2),pq.pop();
cout<<ans<<"\n";
}
// 64 位输出请用 printf("%lld")


深信服公司福利 832人发布