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. 作用: 可用来透明地把对象包装在具有同样接口的另一对象之中,这样可以给一个方法添加一些行为,然后将方法调用传递给原始对象. 可用于为对象增加功能,用来代替大量子类. 装饰者对其组件进 ...
随机推荐
- 提高VS2010运行速度的技巧
任务管理器,CPU和内存都不高,为何?原因就是VS2010不停地读硬盘导致的; 写代码2/3的时间都耗在卡上了,太难受了; 研究发现,VS2010如果你装了VC等语言,那么它就会自动装SQL Serv ...
- 如何查看Mac电脑的处理器核心数目-CPU的核心数目
1.通过点击关于本机来查看
- 传真AT指令部分(参考)
不知道下面的命令是不是通用的,如果有尝试过的师兄给我个回复!! 列出了您的MODEM能理解的传真 AT 命令.每个命令描述包括命令名称.解释和相关参数. 传真命令 命令 描述 +F<comman ...
- Instrumentation 两种方法 premain Agent
由于jvm内部的限制Instrumentation 只能修改方法体 不能动态添加删除方法(安全第一吧!!!!) Premain 对于使用命令行接口的实现,可以将以下选项添加到命令行来启动代理: -ja ...
- dhroid - ioc高级(接口,对象注入)
下面到了接口对象的注入了解冻吧,现在才是我们的重点,这才是ioc的核心思想,上面的都是android的辅助1.5 对象依赖问题 我们先来将一下对象对象依赖的重要性,很多同学可能只学了android没学 ...
- Docker学习计划三:Dockerfile 使用
我们使用 Dockerfile 定义镜像,依赖镜像来运行容器,因此 Dockerfile 是镜像和容器的关键,Dockerfile 可以非常容易的定义镜像内容 首先通过一张图来了解 Docker 镜像 ...
- MFC如何获取控件相对于窗口的左边,以及鼠标相对于控件的位置
CRect rect; CWnd *pWnd = GetDlgItem(IDC_STATIC_PIC); pWnd->GetWindowRect(&rect); ScreenToClie ...
- hdu1540 Tunnel Warfare【线段树】
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast a ...
- 专访知乎张伟:RFC技术评审机制如何助力知乎实现工程文化落地
2017年5月20-21日,MPD工作坊·上海站将于上海徐汇区光大会展中心举办,本届MPD工作坊请到了知乎工程高级总监张伟进行主题为<工程师文化落地6项指南>的3小时深度分享.在工作坊举办 ...
- PyQT5-QCalendarWidget 日历显示
""" QCalendarWidget:提供了日历插件 Author:dengyexun DateTime:2018.11.22 """ f ...