题解:P14333 [JOI2021 预选赛 R2] 安全检查 / Safety Inspection
二分答案
倒着考虑每个设施。完成第
可以发现,可能存在一个人不需要把自己时间全放在
所以 check 这样写:
bool chk(int t) {
int res = 0, cnt = 0;
for (int i = n; i; -- i ) {
if (cnt < b[i]) {
int k = (b[i] - cnt + t - a[i] - 1) / (t - a[i]);
res += k;
cnt = k * (t - a[i]) + cnt - b[i];
} else {
cnt -= b[i];
}
if (res > m) return false;
}
return true;
}