Files
python/GESP/Level5/P1843_ErFen.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

38 lines
841 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
const int N = 5e5 + 10;
using namespace std;
int n, a, b, mx;
int w[N];
bool check(int mid) {
int sum = 0;
for (int i = 0; i < n; i++) {
int re = w[i] - (mid * a);
if (re > 0)
sum += re / b + (re % b != 0); // 整除则为 re/b,否则是re/b+1
}
return sum <= mid; // 如果sum小于mid,表示mid长的时间足够用
}
int main() {
cin >> n >> a >> b;
mx = -1;
for (int i = 0; i < n; i++) {
cin >> w[i];
mx = max(mx, w[i]); // 找出湿度最大值
}
int l = 1, r = mx / a + (mx % a != 0);
// r是最大湿度除以每分钟自然干的速度,也就是全指望自然干的时间
while (l < r) {
int mid = (l + r) >> 1;
if (check(mid))
r = mid;
else
l = mid + 1;
}
printf("%d\n", r);
return 0;
}