hdu6000 Wash ccpc-20162017-finals B Wash
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6000
题目:
Wash
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 64000/64000 K (Java/Others)
Total Submission(s): 1250 Accepted Submission(s): 331
At any point in time, each machine may only be processing at most one load of laundry.
As one might expect, Panda wants to wash and then dry each of his L loads of laundry. Each load of laundry will go through the following steps in order:
1. A non-negative amount of time after Panda arrives at the laundromat, Panda places the load in an unoccupied washing machine i.
2. Wi minutes later, he removes the load from the washing machine, placing it in a temporary holding basket (which has unlimited space)
3. A non-negative amount of time later, he places the load in an unoccupied dryer j
4. Dj minutes later, he removes the load from the dryer Panda can instantaneously add laundry to or remove laundry from a machine. Help Panda minimize the amount of time (in minutes after he arrives at the laundromat) after which he can be done washing and drying all L loads of laundry!
T test cases follow. Each test case consists of three lines. The first line contains three integer L, N, and M.
The second line contains N integers W1,W2,...,WN representing the wash time of each wash machine.
The third line contains M integers D1,D2,...,DM representing the dry time of each dryer.
limits
∙1≤T≤100.
∙1≤L≤106.
∙1≤N,M≤105.
∙1≤Wi,Di≤109.
1 1 1
1200
34
2 3 2
100 10 1
10 10
Case #2: 12
思路:
第一阶段,正着贪心,用set或优先队列维护,处理出每件衣服出来的时间。
第二阶段,倒着贪心,用set或优先队列维护,然后维护最大值。
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; namespace fastIO{
#define BUF_SIZE 100000
bool IOerror=;
inline char nc(){
static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
if(p1==pend){
p1=buf;
pend=buf+fread(buf,,BUF_SIZE,stdin);
if(pend==p1){
IOerror=;
return -;;
}
}return *p1++;
}
inline bool blank(char ch){
return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';
}
inline bool read(int &x){
char ch;
while(blank(ch=nc()));
if(IOerror)return ;
for(x=ch-'';(ch=nc())>=''&&ch<='';x=x*+ch-'');
return ;
}
#undef BUF_SIZE
};
using namespace fastIO; struct node
{
LL id,end;
node(){}
node(LL x,LL y){id=x,end=y;}
bool operator < (const node &ta) const
{
return end>ta.end||(end==ta.end&&id<ta.id);
}
};
int n,m,l,ta[K],tb[K];
LL ed[K];
priority_queue<node>pa,pb; int main(void)
{
//freopen("in.acm","r",stdin);
int t,cs=;read(t);
while(t--)
{
LL ans=;
while(pa.size())pa.pop();
while(pb.size())pb.pop();
read(l),read(n),read(m);
for(int i=;i<=n;i++)
read(ta[i]),pa.push(node(i*1LL,1LL*ta[i]));
for(int i=;i<=l;i++)
{
LL tm=pa.top().end,id=pa.top().id;
ed[i]=tm;
pa.pop(),pa.push(node(id,tm+ta[id]));
}
for(int i=;i<=m;i++)
read(tb[i]),pb.push(node(i*1LL,1LL*tb[i]));
for(int i=l;i;i--)
{
LL tm=pb.top().end,id=pb.top().id;
ans=max(ans,ed[i]+tm);
pb.pop(),pb.push(node(id,tm+tb[id]));
}
printf("Case #%d: %lld\n",cs++,ans);
}
return ;
}
hdu6000 Wash ccpc-20162017-finals B Wash的更多相关文章
- CCPC 2016-2017, Finals Solution
A - The Third Cup is Free 水. #include<bits/stdc++.h> using namespace std; ; int n; int arr[max ...
- CCPC 2016-2017, Finals
A. HDU 5999 The Third Cup is Free 简单模拟. B. HDU 6000 Wash n 件衣服, m 个洗衣机,k 个烘干机.每个洗衣机和烘干机需要不同的时间.问 n 件 ...
- CCPC 2017-2018, Finals Solution
A - Dogs and Cages 水. #include <bits/stdc++.h> using namespace std; int t; double n; int main( ...
- HZNU_TI1050 训练实录
菜鸡队训练实录 比赛记录:[名称:奖项 / 排名] 2018: ZJPSC Bronze / 86 CCPC Jilin ...
- (五)适配器模式-C++实现
将一个类的接口转换成客户希望的另外一个接口.Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 该模式中有三种角色: 1.目标:是一个抽象类,它是客户想使用的接口 2.被适配 ...
- javascript设计模式-装饰模式
装饰模式:在不改变原类(对象)和继承的情况下动态扩展对象功能,通过包装一个对象来实现一个新的具有原对象相同接口的新的对象.在设计原则中,有一条,多用组合,少用继承,装饰模式正是这一原则的体现. UML ...
- 【读书笔记】读《JavaScript设计模式》之装饰者模式
一.定义 装饰者模式可用来透明地把对象包装在具有同样接口的另一个对象之中.这样一来,你可以给一个方法添加一些行为,然后将方法调用传递给原始对象.相对于创建子类来说,使用装饰者对象是一种更灵活的选择(装 ...
- 读书笔记之 - javascript 设计模式 - 装饰者模式
本章讨论的是一种为对象增添特性的技术,它并不使用创建新子类这种手段. 装饰者模式可以透明地把对象包装在具有同样接口的另一对象之中,这样一来,你可以给一些方法添加一些行为,然后将方法调用传递给原始对象. ...
- Ruby小例子
1.ruby定义函数与执行函数案例 def fact(n) ) end end print fact() 结果: 24 2.一个小例子 words = [)] print "guess?\n ...
- JavaScript设计模式(8)-装饰者模式
装饰者模式 1. 作用: 可用来透明地把对象包装在具有同样接口的另一对象之中,这样可以给一个方法添加一些行为,然后将方法调用传递给原始对象. 可用于为对象增加功能,用来代替大量子类. 装饰者对其组件进 ...
随机推荐
- C# 创建txt文本
1.创建txt文本 /// <summary> /// log日志,txt的 /// </summary> /// <param name="Log1" ...
- 兵器簿之github的配置和使用
1.注册一个github 账号,这个大家都懂得了啊 2.配置 (1 检查:进入终端,在用户目录下输入: ls -al ~/.ssh 得到下图代表本地没有配置过github 过. (2 创建一个目录,输 ...
- mysql limit 优化
1.当取出的数据超过20%时,优化器不会使用索引,而是全表扫描: 2.limit和offset的问题,其实是offset的问题,它会导致mysql扫描大量不需要的行然后删掉 如: select * f ...
- PostgreSql数据库查询表信息/列信息(列ID/列名/数据类型/长度/精度/是否可以为null/默认值/是否自增/是否是主键/列描述)
查询表信息(表名/表描述) select a.relname as name , b.description as value from pg_class a ) b on a.oid = b.obj ...
- Java-查询已创建了多少个对象
//信1603 //查询创建了多少个对象//2017.10.19public class Lei {//记录对象个数 ;//生成一个对象就自加加 public Lei() { x++; }public ...
- PyQT5-QCheckBox按钮
""" QcheckBox:单选框有两种状态:开和关.通常跟标签一起使用,用在一些激活或者关闭的场景 Author:dengyexun DateTime:2018.11. ...
- Effective Objective-C 笔记之熟悉OC
1.在一个类的头文件中尽量少引用其他头文件 如果Person.h 引入了EmployeePerson.h,而后续又有其他类如Human.h又引入了Person.h, 那么EmployeePerson. ...
- 【RBAC】打造Web权限控制系统
引言 权限系统模块对于互联网产品是一个非常重要的功能,可以控制不同的角色合理的访问不同的资源从而达到安全访问的作用 此外本次课程有视频讲解: http://www.imooc.com/learn/79 ...
- Find a way--hdu2612
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2612 广搜题 注意:可能存在一个@两人都不能达到: 3 3 Y#@ .M# @.. #include ...
- 2015 湘潭大学程序设计比赛(Internet)--E题--烦人的异或
烦人的异或 Accepted : 27 Submit : 102 Time Limit : 5000 MS Memory Limit : 65536 KB 题目描述 如下图,有一N*M的表格, ...