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. 作用: 可用来透明地把对象包装在具有同样接口的另一对象之中,这样可以给一个方法添加一些行为,然后将方法调用传递给原始对象. 可用于为对象增加功能,用来代替大量子类. 装饰者对其组件进 ...
随机推荐
- Metrics.Net构建指标监控中心
Metrics.NET(https://github.com/etishor/Metrics.NET)是一个给CLR 提供度量工具的包,它是移植自Java的metrics,支持的平台 .NET 4.5 ...
- Java中的一些性能监控和故障分析工具
这些工具都在JDK的bin目录下,如果配置了java的环境变量,可以直接在命令行里调用这些小工具 jps 查看java进程信息 jstat java虚拟机状态监控工具 jstat -gc(或 -gcn ...
- memcached stats 命令
STAT pid 1552 STAT uptime 3792 STAT time 1262517674 STAT version 1.2.6 STAT pointer_size 32 STAT cur ...
- Android 国内集成使用谷歌地图
extends:http://blog.csdn.net/qduningning/article/details/44778751 由于众做周知的原因在国内使用谷歌地图不太方便,在开发中如果直接使用会 ...
- Logstash在Linux上安装部署
Logstash 简介: Logstash 是一个实时数据收集引擎,可收集各类型数据并对其进行分析,过滤和归纳.按照自己条件分析过滤出符合数据导入到可视化界面.它可以实现多样化的数据源数据全量或增量传 ...
- ELK(使用RPM包安装配置ELK)
1,安装环境查看 2,下载rmp包 下载地址:https://www.elastic.co/cn/downloads 分别下载最新rmp包 elasticsearch-6.2.4.rpm logsta ...
- POJ - 1101 The Game dfs
题意:给你一个地图,上面有一些‘X',给你起点终点,让你输出从起点到终点的路径中转向(改变方向)次数最少的路径,注意,不能穿过别的’X'并且可以超过边界 题解:关于超过边界,只要在外围多加一圈‘ ’. ...
- CodeForces - 156B Suspects 逻辑 线性 想法 题
题意:有1~N,n(1e5)个嫌疑人,有m个人说真话,每个人的陈述都形如X是凶手,或X不是凶手.现在给出n,m及n个陈述(以+x/-X表示)要求输出每个人说的话是true ,false or notd ...
- Oracle备份恢复之逻辑备份
exp 交互模式:导出scott用户下的emp表. [oracle@localhost ~]$ exp Export: Release 10.2.0.1.0 - Production on Thu N ...
- C# ArcEngine TOCControl上实现右键
第一种方法:使用contextMenuStrip控件 1.新建一个窗体AttributeTable,并定义一个全局变量mLayer,让主窗体里面的axMapControl1的layer传进来,从而获取 ...