• LOJ#6035. 「雅礼集训 2017 Day4」洗衣服


    传送门

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

    # 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;
    }
    
  • 相关阅读:
    立体图
    旅行家的预算
    洛谷P多米诺骨牌
    洛谷P2331最大子矩阵
    理想的正方形
    2015 ACM/ICPC Asia Regional Hefei Online Find a path
    Atcoder abc 138 F
    Atcoder abc 138 E String of Impurity
    zlb的8.19考试
    Atcoder abc 138
  • 原文地址:https://www.cnblogs.com/cjoieryl/p/10320361.html
Copyright © 2020-2023  润新知