D e s c r i p t i o n Description Description
有 n n n件衣服,第 i i i件衣服的湿度为 h i h_i hi。
在自然条件下,每件衣服每分钟都可以自然晒干 A A A点湿度。
在烘干机作用下,可以选择一件衣服,用一分钟的时间晒干B点湿度。
求出晒干所有衣服的最少时间(湿度为 0 0 0为干)。
I n p u t Input Input
第一行三个正整数 N , A , B N,A,B N,A,B。
接下来 N N N行,第 i i i行一个正整数,表示第 i i i件衣服的湿度 h i h_i hi。
O u t p u t Output Output
输出一个数,表示晒干所有衣服的最少时间。
S a m p l e Sample Sample I n p u t Input Input
3 2 1
1
2
3
S a m p l e Sample Sample O u t p u t Output Output
1
H i n t Hint Hint
对于 100 % 100\% 100%的数据, 1 ≤ N , A , B , H i ≤ 5 ∗ 1 0 5 1 \leq N,A,B,H_i \leq 5 * 10^5 1≤N,A,B,Hi≤5∗105 。
T r a i n Train Train o f of of T h o u g h t Thought Thought
首先烘干机肯定是要给湿度最大的衣服
所以可以用一个大根堆存衣服湿度
然后每次给top减B
最后当top-A*time<=0就代表全部干了
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#define ll long long
using namespace std;
priority_queue<int> hy;
ll n, a, b, k;
int main()
{
scanf("%lld%lld%lld", &n, &a, &b);
for(int i = 1; i <= n; ++i)
scanf("%lld", &k), hy.push(k);
ll t = 0;
while(hy.top() - t * a > 0)
{
t++;
ll x = hy.top();
hy.pop();
hy.push(x - b);
}
printf("%lld", t);
return 0;
}