Job Processing
IOI'96

A factory is running a production line that requires two operations to be performed on each job: first operation "A" then operation "B". Only a certain number of machines are capable of performing each operation.

Figure 1 shows the organization of the production line that works as follows. A type "A" machine takes a job from the input container, performs operation "A" and puts the job into the intermediate container. A type "B" machine takes a job from the intermediate container, performs operation "B" and puts the job into the output container. All machines can work in parallel and independently of each other, and the size of each container is unlimited. The machines have different performance characteristics, a given machine requires a given processing time for its operation.

Give the earliest time operation "A" can be completed for all N jobs provided that the jobs are available at time 0. Compute the minimal amount of time that is necessary to perform both operations (successively, of course) on all N jobs.

PROGRAM NAME: job

INPUT FORMAT

Line 1: Three space-separated integers:

  • N, the number of jobs (1<=N<=1000).
  • M1, the number of type "A" machines (1<=M1<=30)
  • M2, the number of type "B" machines (1<=M2<=30)
Line 2..etc: M1 integers that are the job processing times of each type "A" machine (1..20) followed by M2 integers, the job processing times of each type "B" machine (1..20).

SAMPLE INPUT (file job.in)

5 2 3
1 1 3 1 4

OUTPUT FORMAT

A single line containing two integers: the minimum time to perform all "A" tasks and the minimum time to perform all "B" tasks (which require "A" tasks, of course).

SAMPLE OUTPUT (file job.out)

3 5

——————————————————————————————————————

假设A,B都获得了n个工件然后进行加工,我们通过循环判断哪个用时最少交给哪个,最后我们得到了A处理第1,2,3,4……工件所用的时间B处理第1,2,3,4工件所用的时间

他们是一个递增的线段

然后发现A用时最短的应该交给B用时最长的

 /*
ID:ivorysi
PROG:job
LANG:C++
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#define inf 0x7fffffff
#define ivorysi
#define siji(i,x,y) for(int i=(x);i<=(y);++i)
#define gongzi(j,x,y) for(int j=(x);j>=(y);--j)
#define xiaosiji(i,x,y) for(int i=(x);i<(y);++i)
#define sigongzi(j,x,y) for(int j=(x);j>(y);--j)
using namespace std;
int n,m1,m2;
int a[],b[],usea[],useb[];
int spa[],spb[],ans;
void init() {
scanf("%d%d%d",&n,&m1,&m2);
siji(i,,m1) {
scanf("%d",&a[i]);
}
siji(i,,m2) {
scanf("%d",&b[i]);
}
}
void solve() {
init();
int mina,ida,minb,idb;
siji(i,,n) {
mina=usea[]+a[];ida=;
minb=useb[]+b[];idb=;
siji(j,,m1) {
if(usea[j]+a[j]<mina) {
mina=usea[j]+a[j];
ida=j;
}
}
siji(j,,m2) {
if(useb[j]+b[j]<minb) {
minb=useb[j]+b[j];
idb=j;
}
}
usea[ida]=mina;
useb[idb]=minb;
spa[i]=mina;
spb[i]=minb;
}
siji(i,,n) {
ans=max(ans,spa[i]+spb[n-i+]);
}
printf("%d %d\n",mina,ans);
}
int main(int argc, char const *argv[])
{
#ifdef ivorysi
freopen("job.in","r",stdin);
freopen("job.out","w",stdout);
#else
freopen("f1.in","r",stdin);
#endif
solve();
return ;
}

USACO 4.2 Job Processing的更多相关文章

  1. USACO 完结的一些感想

    其实日期没有那么近啦……只是我偶尔还点进去造成的,导致我没有每一章刷完的纪念日了 但是全刷完是今天啦 讲真,题很锻炼思维能力,USACO保持着一贯猎奇的题目描述,以及尽量不用高级算法就完成的题解……例 ...

  2. usaco training 4.2.3 Job Processing 题解

    Job Processing题解 IOI'96 A factory is running a production line that requires two operations to be pe ...

  3. 洛谷P2751 [USACO4.2]工序安排Job Processing

    P2751 [USACO4.2]工序安排Job Processing 18通过 78提交 题目提供者该用户不存在 标签 难度普及+/提高 提交  讨论  题解 最新讨论 暂时没有讨论 题目描述 一家工 ...

  4. USACO . Your Ride Is Here

    Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often co ...

  5. OLTP(on-line transaction processing)与OLAP(On-Line Analytical Processing)

    OLTP与OLAP的介绍 数据处理大致可以分成两大类:联机事务处理OLTP(on-line transaction processing).联机分析处理OLAP(On-Line Analytical ...

  6. 【USACO 3.1】Stamps (完全背包)

    题意:给你n种价值不同的邮票,最大的不超过10000元,一次最多贴k张,求1到多少都能被表示出来?n≤50,k≤200. 题解:dp[i]表示i元最少可以用几张邮票表示,那么对于价值a的邮票,可以推出 ...

  7. USACO翻译:USACO 2013 NOV Silver三题

    USACO 2013 NOV SILVER 一.题目概览 中文题目名称 未有的奶牛 拥挤的奶牛 弹簧牛 英文题目名称 nocow crowded pogocow 可执行文件名 nocow crowde ...

  8. USACO翻译:USACO 2013 DEC Silver三题

    USACO 2013 DEC SILVER 一.题目概览 中文题目名称 挤奶调度 农场航线 贝西洗牌 英文题目名称 msched vacation shuffle 可执行文件名 msched vaca ...

  9. USACO翻译:USACO 2014 DEC Silver三题

    USACO 2014 DEC SILVER 一.题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback ma ...

随机推荐

  1. wepy

    npm install -g cnpm --registry=https://registry.npm.taobao.org https://blog.csdn.net/qq_40414159/art ...

  2. SourceTree使用SSH克隆码云项目

    SourceTree使用SSH克隆码云项目 觉得有用的话,欢迎一起讨论相互学习~Follow Me SourceTree使用SSH克隆码云项目 参考文献 https://blog.csdn.net/q ...

  3. ASP.NET IOC之 AutoFac的认识和结合MVC的使用

    这几天研究了解发现AutoFac是个牛X的IOC容器,是.NET领域比较流行的IOC框架之一,传说是速度最快的,~ 据相关资料,相关学习,和认知,遂做了一些整理 优点: 它是C#语言联系很紧密,也就是 ...

  4. poj 1961 Period

    Period http://poj.org/problem?id=1961 Time Limit: 3000MS   Memory Limit: 30000K       Description Fo ...

  5. MYSQL 在当前时间加上或减去一个时间段

    update user set time1=now(),time2=date_add(NOW(), interval 1 MONTH) where id=1; date_add() 增加date_su ...

  6. [转] malloc基本实现

    任何一个用过或学过C的人对malloc都不会陌生.大家都知道malloc可以分配一段连续的内存空间,并且在不再使用时可以通过free释放掉.但是,许多程序员对malloc背后的事情并不熟悉,许多人甚至 ...

  7. python核心编程笔记——Chapter8

    Chapter8.条件和循环 这一章感觉有用的点并不多,在我眼里就只有迭代器,列表解析和生成器表达式值得研究而已. 8.2.循环,难度不大. #!usr/bin/env python #-*-codi ...

  8. oracle主键约束、唯一键约束和唯一索引的区别

    (1)主键约束和唯一键约束均会隐式创建同名的唯一索引,当主键约束或者唯一键约束失效时,隐式创建的唯一索引会被删除: (2)主键约束要求列值非空,而唯一键约束和唯一索引不要求列值非空: (3)相同字段序 ...

  9. css给表格每一列设置不同的样式

    第一列#id table tr td:first-child{ overflow: visible; }第二列table tr td:first-child+td{color:#666;}第三列tab ...

  10. ubuntu16.04 源码方法安装tensorflow

    参考博客:http://blog.csdn.net/zhaoyu106/article/details/52793183/,http://blog.csdn.net/u010900574/articl ...