【题目链接】:http://codeforces.com/problemset/problem/452/D

【题意】



洗衣服有3个步骤,洗,干,叠;

有对应的3种洗衣机,分别有n1,n2,n3台,然后每一种洗衣机,一台完成对应的步骤所需的时间为t1,t2,t3;

已知你有k件衣服要洗;

问你最少需要洗多长时间;

【题解】



用3个优先队列;

维护每一种洗衣机,在何时是处于空闲状态的;(即什么时候会有一件衣服操作完);

每次将时间跳转到;

min{q1.top(),q2.top(),q3.top()};

然后将操作完的衣服放入下一步骤;

然后将正在等待操作的衣服;如果能放入对应的洗衣机,就放入;



【Number Of WA】



0



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0),cin.tie(0) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
const int INF = 0x3f3f3f3f; int k,n1,n2,n3,t1,t2,t3,ans;
int w1,w2,w3;
priority_queue <int,vector<int>,greater<int>> q1,q2,q3; int main(){
//Open();
Close();//scanf,puts,printf not use
//init??????
cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;
w1 = k;
q1.push(INF),q2.push(INF),q3.push(INF);
while (w1 || w2 || w3 || (int) q1.size()>1 || (int) q2.size()>1 || (int) q3.size()>1){
ans = min(q1.top(),min(q2.top(),q3.top()));
if (ans==INF) ans = 0;
while (q1.top()<=ans){
q1.pop();
w2++;
}
while (q2.top()<=ans){
q2.pop();
w3++;
}
while (q3.top()<=ans){
q3.pop();
}
while (w1 && (int) q1.size()<=n1){
w1--;
q1.push(ans+t1);
}
while (w2 && (int) q2.size()<=n2){
w2--;
q2.push(ans+t2);
}
while (w3 && (int) q3.size()<=n3){
w3--;
q3.push(ans+t3);
}
}
cout << ans << endl;
return 0;
}

【codeforces 452D】Washer, Dryer, Folder的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  3. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  4. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  5. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  8. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

  9. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

随机推荐

  1. Java基础学习总结(61)——Java项目开发要注意的60个问题

    1. 首先写代码的时候最好不要有缺陷.最好的修复方法就是让 bug 胎死腹中. 良好的单元测试 强制数据库约束 使用输入验证框架 避免未实现的"else"条件 在应用到主程序之前知 ...

  2. CodeForcesGym 100641D Generalized Roman Numerals

    Generalized Roman Numerals Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on  ...

  3. ZOJ 3885 The Exchange of Items

    The Exchange of Items Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. O ...

  4. COCOS2DX 3.0 优化提升渲染速度 Auto-batching

    COCOS2DX 3.0 优化提升渲染速度 Auto-batching 近期在看COCOS2DX 3.0的Auto-batching合批与Auto Culling动态缩减功能以下就来细致看看吧:整合好 ...

  5. Tom和Jerry来了,Tom和Jerry走了——北漂18年(38)

    上次讲到跟我同一时候入职的女销售走了. 回忆起来,她的问题多半是技巧足够,脑子不足够,走了之后再没联系.不久之后,在老板的要求之下.LilyG又招聘了两位男销售,英文名字非常登对一个叫Tom,一个叫J ...

  6. eclipse转Android studio遇到的那些坑

           公司项目有导入10多个libray,还有涉及ndk,转Android studio时碰到不少问题.前后大概花费5个工作日,中间各种奇葩bug,各种编译出错,非常多还有没错误提示.一度想过 ...

  7. Linux uname 命令 打印系统信息

    转自:https://www.jb51.net/LINUXjishu/417626.html 1.概述 打印系统信息 2.命令格式 uname [OPTION]... 3.常用命令参数 打印一些系统信 ...

  8. UVa512 追踪电子表格中的单元格

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. 前端将图片二进制流显示在html端

    工作中碰到的问题,在处理接口返回的验证码图片时,由于返回的是encode编码代码,在js端获取到数据之后,通过函数encodeURI()来进行解码,之后可以通过在src中设置来实现图片显示:

  10. Oracle学习系类篇(一)

    1.表空间介绍 oarcle数据库真正存放数据的是数据文件(data files),Oarcle表空间(tablespaces)实际上是一个逻辑的概念,他在物理上是并不存在的,那么把一组data fi ...