传送门

先处理出每一件衣服最早什么时候洗完,堆+贪心即可
然后同样处理出每件衣服最早什么时候烘干
然后倒序相加取最大值

# 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\n", ans);
	return 0;
}

相关文章:

  • 2022-12-23
  • 2022-01-05
  • 2021-09-29
  • 2022-02-10
  • 2022-12-23
  • 2021-06-16
  • 2021-12-06
  • 2021-11-14
猜你喜欢
  • 2021-10-25
  • 2021-09-27
  • 2021-06-29
  • 2022-02-18
  • 2022-12-23
  • 2021-08-10
  • 2021-07-04
相关资源
相似解决方案