P1843 奶牛晒衣服
题解:每次用烘衣机来烘最湿的衣服,然后减去烘衣机烘干的湿度,累计自然晒干需要的天数,每次取最湿的衣服用优先队列维护即可。
代码
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+10;
priority_queue<int> pq;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.in","r",stdin);
#endif
int n,A,B,x;
cin>>n>>A>>B;
for(int i = 0; i < n; ++i){
cin>>x;
pq.push(x);
}
int t = 0;
while(!pq.empty()){
int cur = pq.top();
pq.pop();
if(cur - t * A <= 0){
break;
}
t++;
pq.push(cur - B);
}
printf("%d\n",t);
return 0;
}