先处理出每一件衣服最早什么时候洗完,堆+贪心即可
然后同样处理出每件衣服最早什么时候烘干
然后倒序相加取最大值
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn(1e5 + 5);
int l, n, m, d[maxn], w[maxn];
ll ans, tim1[maxn * 10], tim2[maxn * 10];
priority_queue < pair <ll, int> > hp;
int main() {
int i, j, k;
scanf("%d%d%d", &l, &n, &m);
for (i = 1; i <= n; ++i) scanf("%d", &w[i]), hp.push(make_pair(-w[i], i));
for (i = 1; i <= m; ++i) scanf("%d", &d[i]);
for (i = 1; i <= l; ++i) {
j = hp.top().second, tim1[i] = -hp.top().first, hp.pop();
hp.push(make_pair(-w[j] - tim1[i], j));
}
while (!hp.empty()) hp.pop();
for (i = 1; i <= m; ++i) hp.push(make_pair(-d[i], i));
for (i = 1; i <= l; ++i) {
j = hp.top().second, tim2[i] = -hp.top().first, hp.pop();
hp.push(make_pair(-d[j] - tim2[i], j));
ans = max(ans, tim2[i] + tim1[l - i + 1]);
}
printf("%lld
", ans);
return 0;
}